D
dlarock
I wrote the following to do an MD5 hash. However, I have a problem (I
think) with the conversion from the Byte[] MD5 hash back to string.
Watching this through the debugger it appears as if the MD5 is
computing the right Byte[] for the hash when compared to other MD5 hash
generators online. However, when I attempt to convert it back to tring
using the line
String outputData = textConverter.GetString( result ) ;
I essentially get garbage. Any thoughts on what I am doing wrong?
Does the MD5 hash not generate a UTF8 byte array?
Amy.
UTF8Encoding textConverter = new UTF8Encoding();
String inputData = "" ;
Console.Write( "Enter a string: " ) ;
inputData = Console.ReadLine() ;
MD5 md5 = new MD5CryptoServiceProvider();
byte[] result = md5.ComputeHash( textConverter.GetBytes( inputData ) );
String outputData = textConverter.GetString( result ) ;
Console.WriteLine( "MD5 Hash: " + outputData ) ;
Console.ReadLine() ;
think) with the conversion from the Byte[] MD5 hash back to string.
Watching this through the debugger it appears as if the MD5 is
computing the right Byte[] for the hash when compared to other MD5 hash
generators online. However, when I attempt to convert it back to tring
using the line
String outputData = textConverter.GetString( result ) ;
I essentially get garbage. Any thoughts on what I am doing wrong?
Does the MD5 hash not generate a UTF8 byte array?
Amy.
UTF8Encoding textConverter = new UTF8Encoding();
String inputData = "" ;
Console.Write( "Enter a string: " ) ;
inputData = Console.ReadLine() ;
MD5 md5 = new MD5CryptoServiceProvider();
byte[] result = md5.ComputeHash( textConverter.GetBytes( inputData ) );
String outputData = textConverter.GetString( result ) ;
Console.WriteLine( "MD5 Hash: " + outputData ) ;
Console.ReadLine() ;