Click here to Skip to main content
15,885,895 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
in my program, I am encrypting and decrypting a .dat file using the Triple DES algorithm. It encrypts but all the characters in the desination file are replaced with these characters: �$ï/‹%

Here's the code:

C#
public byte[] Transform(byte[] input, ICryptoTransform CryptoTransform)
       {
           // create the necessary streams
           MemoryStream memStream = new MemoryStream();
           CryptoStream cryptStream = new CryptoStream(memStream, CryptoTransform, CryptoStreamMode.Write);

           // transform the bytes as requested
           cryptStream.Write(input, 0, input.Length);
           cryptStream.FlushFinalBlock();

           // Read the memory stream and
           // convert it back into byte array
           memStream.Position = 0;
           byte[] result = memStream.ToArray();

           // close and release the streams
           memStream.Close();
           cryptStream.Close();

           // hand back the encrypted buffer
           return result;
       }
Posted
Comments
[no name] 15-Jun-14 7:04am    
And your question is....?

1 solution

What did you expect encryption to do? Change it to text which says "This is encrypted data."?


Encrypted data is not meant to be readable: that's the whole idea. When you use Triple DES it returns an array of bytes which are encrypted...because it is supposed to.
 
Share this answer
 
Comments
Kornfeld Eliyahu Peter 15-Jun-14 7:13am    
Nםםםם! Yםו שרק מםא דקרןםוד!
Noooo! You are not serious!
OriginalGriff 15-Jun-14 7:53am    
ואל תקראו לי שירלי!

Probably...Odd alphabet you have there!
Kornfeld Eliyahu Peter 15-Jun-14 7:57am    
Not bad for Google - only one mistake...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900