Skip to content

Instantly share code, notes, and snippets.

@dreid

dreid/t.py Secret

Created February 26, 2014 19:05
Show Gist options
  • Save dreid/f7183ef663afea65cf6d to your computer and use it in GitHub Desktop.
Save dreid/f7183ef663afea65cf6d to your computer and use it in GitHub Desktop.
from cryptography.hazmat.backends import openssl, commoncrypto, default_backend
from cryptography.fernet import Fernet
def encrypt(backend):
f = Fernet(Fernet.generate_key(), backend=backend)
return f.encrypt(b"my deep dark secret")
print "OpenSSL Version: ", openssl.backend.openssl_version_text()
print "CommonCrypto: ", encrypt(commoncrypto.backend)
print "OpenSSL: ", encrypt(openssl.backend)
print "Default: ", encrypt(default_backend())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment