MCPcopy Create free account
hub / github.com/LaunchPlatform/beanhub-cli / decrypt_file

Function decrypt_file

beanhub_cli/encryption.py:9–25  ·  view source on GitHub ↗
(
    input_file: io.BytesIO, output_file: io.BytesIO, iv: bytes, key: bytes
)

Source from the content-addressed store, hash-verified

7
8
9def decrypt_file(
10 input_file: io.BytesIO, output_file: io.BytesIO, iv: bytes, key: bytes
11):
12 cipher = Cipher(algorithms.AES256(key), modes.CBC(iv))
13 decryptor = cipher.decryptor()
14 padder = padding.PKCS7(128).unpadder()
15 while True:
16 chunk = input_file.read(4096)
17 if not chunk:
18 break
19 decrypted = decryptor.update(chunk)
20 unpadded_chunk = padder.update(decrypted)
21 output_file.write(unpadded_chunk)
22 output_file.write(padder.update(decryptor.finalize()))
23 output_file.write(padder.finalize())
24 output_file.flush()
25 output_file.seek(0)

Callers 3

test_decrypt_fileFunction · 0.90
dumpFunction · 0.85
dumpFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_decrypt_fileFunction · 0.72