Advertisement
Guest User

Untitled

a guest
Aug 7th, 2017
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. import os, sys
  2. from Crypto.Cipher import AES
  3.  
  4. fn = sys.argv[1]
  5. data = open(fn,'rb').read()
  6.  
  7. # Secure CTR mode encryption using random key and random IV, taken from
  8. # http://stackoverflow.com/questions/3154998/pycrypto-problem-using-aesctr
  9. secret = os.urandom(16)
  10. crypto = AES.new(os.urandom(32), AES.MODE_CTR, counter=lambda: secret)
  11.  
  12. encrypted = crypto.encrypt(data)
  13. open(fn+'.enc','wb').write(encrypted)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement