def stretch(passw, iv1):
# hash the external iv and the password 8192 times
digest = iv1 + (16 * b"\x00")
for i in range(8192):
passHash = hashes.Hash(hashes.SHA256(), backend=default_backend())
passHash.update(digest)
passHash.update(bytes(passw, "utf_16_le"))
digest = passHash.finalize()
return digest
# encrypting function
# arguments:
# infile: plaintext file path
# outfile: ciphertext file path
# passw: encryption password
# bufferSize: encryption buffer size, must be a multiple of
# AES block size (16)
# using a larger buffer speeds up things when dealing
# with big files
评论列表
文章目录