Skip to content

Instantly share code, notes, and snippets.

@tiagovizoto
Created March 11, 2016 16:43
Show Gist options
  • Save tiagovizoto/04966fa0da96f26129b1 to your computer and use it in GitHub Desktop.
Save tiagovizoto/04966fa0da96f26129b1 to your computer and use it in GitHub Desktop.
cryptography AES in python
from Crypto.Hash import SHA512
from Crypto.Cipher import AES
class CryptKey():
def __init__(self, password):
self.password = password
cipher_text = ""
decryption_suite = ""
def encryption(self):
# Encryption
passwordSHA = SHA512.new(self.password).hexdigest()
encryption_suite = AES.new('This is a key123', AES.MODE_CBC, 'This is an IV456')
self.cipher_text = encryption_suite.encrypt(passwordSHA)
return self.cipher_text
def decryption(self):
# Decryption
decryption_suite = AES.new('This is a key123', AES.MODE_CBC, 'This is an IV456')
plain_text = decryption_suite.decrypt(self.cipher_text)
return SHA512.new(self.password).hexdigest() == plain_text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment