Created
November 18, 2013 20:18
-
-
Save david415/7534597 to your computer and use it in GitHub Desktop.
python nacl secret box
This file contains 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
#!/usr/bin/env python | |
import nacl.secret | |
import nacl.utils | |
key = nacl.utils.random(nacl.secret.SecretBox.KEY_SIZE) | |
box = nacl.secret.SecretBox(key) | |
message = b"secret message" | |
nonce = nacl.utils.random(nacl.secret.SecretBox.NONCE_SIZE) | |
encrypted = box.encrypt(message, nonce) | |
plaintext = box.decrypt(encrypted) | |
print plaintext |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment