Created
March 11, 2016 16:43
-
-
Save tiagovizoto/04966fa0da96f26129b1 to your computer and use it in GitHub Desktop.
cryptography AES in python
This file contains 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
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