Encrypt/Decrypt Rijndael

Eloff

Freshman
Joined
Mar 20, 2003
Messages
35
Location
Canada
I have a problem where a variation of the below functions will encrypt and decrypt text files just fine, but when it comes to an image, the end result is no longer recognizable as an image to system.drawing. I can't figure out why this would be...

Code:
    Public Function ByteEncrypt(ByVal b As Byte(), ByRef Rij As RijndaelManaged) As Byte()        
Return Rij.CreateEncryptor(rijKey, rijIv).TransformFinalBlock(b, 0, b.Length)    
End Function    

Public Function ByteDecrypt(ByVal b As Byte(), ByRef Rij As RijndaelManaged) As Byte()        
Return Rij.CreateDecryptor(rijKey, rijIv).TransformFinalBlock(b, 0, b.Length)    
End Function

The encrpyt was used to write the file and the decrypt to decrypt it.
The second param passed to both functions was:
Private rij As New System.Security.Cryptography.RijndaelManaged()
Thanks a lot!
-Dan
 
Last edited by a moderator:
Back
Top