Namespace

box

crypto.box

Make a public key / private key box

View Source cryptoPrimitives.esm.js, line 145

Example

```
 const obj = { hello: 'world' };
 const pairA = crypto.nacl.box.generateKeyPair();
 const pairB = gcrypto.nacl.box.enerateKeyPair();
 const sharedA = box.before(pairB.publicKey, pairA.secretKey);
 const sharedB = box.before(pairA.publicKey, pairB.secretKey);
 const encrypted = crypto.nacl.box.encrypt(sharedA, obj);
 const decrypted = crypto.nacl.box.decrypt(sharedB, encrypted);
 console.log(obj, encrypted, decrypted);
```

Methods

# static decrypt(secretOrSharedKey, messageWithNonce, key) → {string}

Parameters:
Name Type Description
secretOrSharedKey string
messageWithNonce string
key string

View Source cryptoPrimitives.esm.js, line 197

error
string

# static generateKeyPair() → {object}

View Source cryptoPrimitives.esm.js, line 165

object