forked from RomaniukVadim/hack_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncrypt.py
More file actions
20 lines (16 loc) · 681 Bytes
/
Encrypt.py
File metadata and controls
20 lines (16 loc) · 681 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/python
__author__ = 'kilroy'
# (c) 2014, WasHere Consulting, Inc.
# Written for Infinite Skills
# need pycrypto package
from Crypto.Cipher import AES
# key has to be 16, 24 or 32 bytes long
cryptObj = AES.new("This is my key42", AES.MODE_CBC, "16 character vec")
# notice the spaces -- that's to pad it out to a multiple of 16 bytes
plaintext = "This is some text we need to encrypt because it's very secret "
ciphertext = cryptObj.encrypt(plaintext)
print("Cipher text: ", ciphertext)
# this won't work if the key isn't identical
newcryptObj = AES.new("This is my key42", AES.MODE_CBC, "16 character vec")
result = newcryptObj.decrypt(ciphertext)
print(result)