parent
4e3066be0f
commit
c9d326e926
@ -1,2 +1,3 @@
|
|||||||
pandas
|
pandas
|
||||||
|
pycryptodome
|
||||||
scikit-learn
|
scikit-learn
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
# from https://gist.github.com/flatz/3f242ab3c550d361f8c6d031b07fb6b1
|
||||||
|
|
||||||
|
import os
|
||||||
|
import json
|
||||||
|
|
||||||
|
from Crypto.Protocol.KDF import PBKDF2
|
||||||
|
from Crypto.Hash import SHA1
|
||||||
|
from Crypto.Cipher import AES
|
||||||
|
from Crypto.Util.Padding import unpad
|
||||||
|
|
||||||
|
def aes_decrypt_cbc(key, iv, data):
|
||||||
|
cipher = AES.new(key, AES.MODE_CBC, iv)
|
||||||
|
return cipher.decrypt(data)
|
||||||
|
|
||||||
|
prefix = b'v11'
|
||||||
|
salt = 'saltysalt'
|
||||||
|
derived_key_len = 128 // 8
|
||||||
|
num_iterations = 1003
|
||||||
|
iv = b' ' * 16
|
||||||
|
|
||||||
|
def decrypt_encrypted_key(password, encrypted_key):
|
||||||
|
encrypted_key = bytes.fromhex(encrypted_key)
|
||||||
|
assert encrypted_key.startswith(prefix)
|
||||||
|
encrypted_key = encrypted_key[len(prefix):]
|
||||||
|
|
||||||
|
kek = PBKDF2(password, salt, dkLen = derived_key_len, count = num_iterations, hmac_hash_module = SHA1)
|
||||||
|
decrypted_key = unpad(aes_decrypt_cbc(kek, iv, encrypted_key), block_size = 16).decode('ascii')
|
||||||
|
print('0x' + decrypted_key)
|
Loading…
Reference in new issue