开发者

Rijndael File Chunk Encryption?

开发者 https://www.devze.com 2023-01-08 18:28 出处:网络
I am writing a C# class that reads a file and encrypts using Rijndael algorithm. While testing with a 600MB file, i gets OutOfMemoryException, so planned t开发者_开发百科o read the file in small chun

I am writing a C# class that reads a file and encrypts using Rijndael algorithm.

While testing with a 600MB file, i gets OutOfMemoryException, so planned t开发者_开发百科o read the file in small chunks of 10MB each. Now the problem is that, the decryption process fails for the file whose bytes were encrypted as small chunks.

My question is, whether Rijndael encryption supports encrypting small chunks of data?


Yes, it does, and you should use the CryptoStream class.


Rinjadel is a block based encryption system so it only does small chunks of data anyway - 128bits at a time. You can use the output of a block as an input to the next block.

I think, maybe, the problem is in your implementation rather than the encryption method.

Posting some code would help.

Generally, your implmentation should be:

while (read 128bits from input)
{
   transform
   write 128 bits to output
}

if encrypting  
  write number of bits remaining
  read remaining data
  pad to 128 bits
  transform
  write 128 bits
else
  read number of bits left
  read 128 bits
  transform
  write number of bits left bits
0

精彩评论

暂无评论...
验证码 换一张
取 消