Skip to content

Instantly share code, notes, and snippets.

@lvidarte
Created July 16, 2012 18:41
Show Gist options
  • Save lvidarte/3124233 to your computer and use it in GitHub Desktop.
Save lvidarte/3124233 to your computer and use it in GitHub Desktop.
created from lai
# 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