Created
July 16, 2012 18:41
-
-
Save lvidarte/3124233 to your computer and use it in GitHub Desktop.
created from lai
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
# encryptor.py | |
import sys | |
import os.path | |
from Crypto.PublicKey import RSA | |
PUBLIC_KEY = os.path.join(os.path.expanduser('~'), '.ssh/id_rsa.pub') | |
def encrypt(message): | |
with open(PUBLIC_KEY, 'r') as pub_key: | |
encryptor = RSA.importKey(pub_key) | |
encripted_data = encryptor.encrypt(message, 0) | |
with open('/tmp/encripted-message', 'wb') as file: | |
file.write(encripted_data[0]) | |
if __name__ == '__main__': | |
encrypt(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment