Skip to content

Instantly share code, notes, and snippets.

@tristanwietsma
Created April 30, 2013 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tristanwietsma/5486172 to your computer and use it in GitHub Desktop.
Save tristanwietsma/5486172 to your computer and use it in GitHub Desktop.
Public-Private key encryption example
import rsa
(pubkey, privkey) = rsa.newkeys(512, poolsize=8)
print pubkey
print privkey
msg = "this is a secret message!"
sec = rsa.encrypt(msg, pubkey)
print sec
dec = rsa.decrypt(sec, privkey)
print dec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment