Created
June 22, 2022 23:43
-
-
Save kangfend/bae30f5cd37df56931837f9390cbb289 to your computer and use it in GitHub Desktop.
Decrypt Codeigniter Encryption
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 binascii import unhexlify | |
| from hkdf import Hkdf | |
| import hashlib | |
| from base64 import b64decode | |
| from Crypto.Cipher import AES | |
| from Crypto.Util.Padding import unpad | |
| def decrypt(encryption_key, text): | |
| encryption_key = unhexlify(encryption_key) | |
| key_length = len(encryption_key) | |
| kdf = Hkdf(b"\0" * 64, encryption_key, hash=hashlib.sha512) | |
| data = b64decode(text[128:]) | |
| cipher = AES.new(kdf.expand(b"encryption", key_length), AES.MODE_CBC, data[:AES.block_size]) | |
| return unpad(cipher.decrypt(data[key_length:]), AES.block_size) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requirements: