Last active
April 15, 2020 10:14
-
-
Save jkyberneees/f091d3ef516653b73a3e4bd5a5642889 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const nacl = require('tweetnacl') | |
| nacl.util = require('tweetnacl-util') | |
| // generating key pairs | |
| const bob = nacl.box.keyPair() | |
| const alice = nacl.box.keyPair() | |
| // generating one time nonce for encryption | |
| const nonce = nacl.randomBytes(24) | |
| // message for Alice | |
| const utf8 = 'Hello Alice' | |
| // Bob encrypts message for Alice | |
| const box = nacl.box( | |
| nacl.util.decodeUTF8(utf8), | |
| nonce, | |
| alice.publicKey, | |
| bob.secretKey | |
| ) | |
| // somehow send this message to Alice | |
| const message = {box, nonce} | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Generating key pairs: