Skip to content

Instantly share code, notes, and snippets.

@teh
Created February 22, 2012 16:28
Show Gist options
  • Save teh/1885886 to your computer and use it in GitHub Desktop.
Save teh/1885886 to your computer and use it in GitHub Desktop.
RSA in 3 lines
def rsa(m, key, n):
h = '{:x}'.format(pow(int(m.encode('hex'), 16), key, n))
return ('0'+h if len(h) % 2 else h).decode('hex')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment