(data, args)
| 10 | return sha.digest() |
| 11 | |
| 12 | def process(data, args): |
| 13 | try: |
| 14 | from Crypto.Cipher import AES |
| 15 | from Crypto.Util.Padding import pad |
| 16 | except Exception: |
| 17 | raise RuntimeError('pycryptodome is required for aes plugin') |
| 18 | |
| 19 | # generate key and iv |
| 20 | key = os.urandom(32) |
| 21 | iv = os.urandom(16) |
| 22 | |
| 23 | padded_data = pad(data, AES.block_size) |
| 24 | cipher = AES.new(key, AES.MODE_CBC, iv) |
| 25 | encrypted = cipher.encrypt(padded_data) |
| 26 | hash1 = sha256_bytes(data) |
| 27 | final = key + iv + hash1 + encrypted |
| 28 | return final |
nothing calls this directly
no test coverage detected