Created
May 2, 2015 15:49
-
-
Save freretuc/f5722cfc0b50c6278ae5 to your computer and use it in GitHub Desktop.
Crypting with python
This file contains hidden or 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
| from Crypto.PublicKey import RSA | |
| from Crypto.Cipher import PKCS1_OAEP | |
| from requests import get | |
| from base64 import b64encode | |
| def encode(publickey, content): | |
| rsakey = RSA.importKey(publickey) | |
| rsakey = PKCS1_OAEP.new(rsakey) | |
| return b64encode(rsakey.encrypt(content)) | |
| content = "secret" | |
| publickey = open("public.pem","r") | |
| crypted = encode(publickey, content) | |
| print "Plain : " + content | |
| print "Crypted : " + crypted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment