Created
May 14, 2016 16:52
-
-
Save hackerdem/bc9f8999e87195498fdd41abcadb765c to your computer and use it in GitHub Desktop.
simple AES encryption and decryption
This file contains hidden or 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.Cipher import AES | |
from Crypto import Random | |
def encrypt(key,message): | |
cipher=AES.new(key,AES.MODE_CFB,iv) | |
msg=cipher.encrypt(message) | |
print(msg) | |
return msg | |
def decrypt(key,msg): | |
dec=AES.new(key,AES.MODE_CFB,iv) | |
return dec.decrypt(msg).decode('ascii') | |
if __name__=='__main__': | |
global iv | |
iv=Random.new().read(AES.block_size) | |
key='wwwhackerdem.com' | |
message='You will newer walk alone' | |
print(decrypt(key,encrypt(key, message))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you for the code , can you explain how i can encrypts the data while transfer from one database and insert into another database?
example :
select userid,pass,email from user; >>>>> database 1
{i need method to encrypts the data before insert.}
insert into user2 values(userid,pass,email)>>>> database 2
i hope you got my point , thank you