Skip to content

Commit

Permalink
CHANGE: code example
Browse files Browse the repository at this point in the history
  • Loading branch information
go-compile committed Jun 16, 2022
1 parent 50d0df1 commit 5184783
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 25 deletions.
6 changes: 0 additions & 6 deletions encrypt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,6 @@ func TestEncryptP512t1(t *testing.T) {
t.Fatal(err)
}

// Set the options
container.MetaData.ArgonIterations = 4
container.MetaData.ArgonMemory = 32 * 1024
container.MetaData.ArgonParallelism = 4
container.MetaData.ArgonKeyLen = 32

data, err := container.Marshal(pub, []byte(key))
if err != nil {
t.Fatal(err)
Expand Down
39 changes: 20 additions & 19 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,38 +97,39 @@ import (
"fmt"
"log"

"github.com/1william1/ecc"
"github.com/go-compile/rome/brainpool"
"github.com/go-compile/qrsecrets"
)

func main() {
secret := "Hello this is my secret"
hash := qrsecrets.HashSHA256
curve := elliptic.P256()
key := "Password123"

c, err := qrsecrets.NewContainer(
curve,
hash,
[]byte(secret),
64-int32(len(secret)),
)
msg := []byte("My secret message.")
key := "password123SECURE"

priv, err := brainpool.GenerateP512t1()
if err != nil {
log.Fatal(err)
t.Fatal(err)
}

private, err := ecc.GenerateKey(curve)
pub := priv.Public()

// === ENCRYPT
container, err := qrsecrets.NewContainer(pub.Name(), qrsecrets.HashSHA256, msg, 10)
if err != nil {
log.Fatal(err)
t.Fatal(err)
}

buf := bytes.NewBuffer(nil)
if err := c.Encode(buf, private.Public, []byte(key)); err != nil {
log.Fatal(err)
data, err := container.Marshal(pub, []byte(key))
if err != nil {
t.Fatal(err)
}

// === DECRYPT
container, err = qrsecrets.DecodeContainer(bytes.NewBuffer(data), priv, []byte(key))
if err != nil {
t.Fatal(err)
}

fmt.Println(buf.Bytes())
fmt.Println(string(container.CipherText.Plaintext))
}
```

Expand Down

0 comments on commit 5184783

Please sign in to comment.