Skip to content

Instantly share code, notes, and snippets.

@noqqe
Created December 25, 2015 21:02
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 noqqe/a9bccaa016d8e3562cad to your computer and use it in GitHub Desktop.
Save noqqe/a9bccaa016d8e3562cad to your computer and use it in GitHub Desktop.
Simple library based encryption and decryption with python
#!/usr/bin/env python2
from simplecrypt import encrypt, decrypt
import getpass
# read inputs
msg = raw_input('Message: ')
pw = getpass.getpass('Password: ')
ciphertext = encrypt(pw, msg)
# write cipher to file
with open("/tmp/crypt.txt", "w") as f:
f.write(ciphertext)
f.close()
# read cipher from file
with open("/tmp/crypt.txt", "r") as f:
ciph = f.read()
f.close()
# decrypt and display
plaintext = decrypt(pw, ciph)
print(plaintext)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment