Namespace

secretBox

crypto.secretBox

Make a public key / private key box

View Source cryptoPrimitives.esm.js, line 34

Example

```
 const key = generateKey()
 const obj = { "hello": "world" }
 const encrypted = crypto.nacl.secretBox.encrypt(obj, key)
 const decrypted = crypto.nacl.secretBox.decrypt(encrypted, key)
 console.log(decrypted, obj) // should be shallow equal
```

Methods

# static decrypt(msg, key) → {object}

Parameters:
Name Type Description
msg string
key string

View Source cryptoPrimitives.esm.js, line 112

  • Could not decrypt message
error
object

# static encrypt(json, key) → {string}

Parameters:
Name Type Description
json object
key string

View Source cryptoPrimitives.esm.js, line 61

Error
string

# static keyGen(input)

Parameters:
Name Type Description
input *

View Source cryptoPrimitives.esm.js, line 50