我正在尝试解密加密文件。加密文件大小为0.97 GB。解密对于较小尺寸的文件非常适用。
请找到我有解密的代码。
def do_encrypt
encrypted_file = File.new(output_file, 'wb')
encrypted_output = encrypt(File.open(file, 'rb'))
encrypted_file.write(encrypted_output)
encrypted_file.close
end
def decrypt(io)
aes = OpenSSL::Cipher::Cipher.new("AES-256-CBC")
aes.decrypt
aes.key = "cryptoKeyString"
aes.iv = "ivString"
aes.update(io.read) + aes.final # code is breaking here
end
我在系统中有足够的RAM内存,超过4GB空闲。我在控制台上记录了以下错误。
encrypt_decrypt.rb:80:in `update': failed to allocate memory (NoMemoryError)
from encrypt_decrypt.rb:80:in `decrypt'
from encrypt_decrypt.rb:62:in `do_decrypt'
from encrypt_decrypt.rb:47:in `run'
from encrypt_decrypt.rb:85:in `<main>'