Skip to content

Instantly share code, notes, and snippets.

@david415
Created November 18, 2013 20:18
Show Gist options
  • Save david415/7534597 to your computer and use it in GitHub Desktop.
Save david415/7534597 to your computer and use it in GitHub Desktop.
python nacl secret box
#!/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