sha1 problem

L

Linda

I'm I'm trying to compare 2 hash values using sha1 one written in vb.net
and the other in Python.

The value I get in my vb.net code does not match the python code, or any
other hash calulator I have used.

Here is the .net code:
-----------------------------------------------
Dim UE As New UnicodeEncoding
Dim SHAhash As New SHA1Managed
Dim SHA1HASHValue() As Byte
Dim MessageBytes As Byte() = UE.GetBytes(TB_Input.Text)
SHA1HASHValue = SHAhash.ComputeHash(MessageBytes)
Dim b As Byte
Dim strHex As String
For Each b In SHA1HASHValue
strHex += String.Format("{0:x2}", b)
Next
LB_Output.Text = strHex
 
J

Joe Kaplan \(MVP - ADSI\)

I get the same value as your hash calculator when I use ASCIIEncoding or
UTF8Encoding. Therefore, the question is how is the python code converting
your string to an array of bytes. Each of those encodings will produce
different byte arrays, depending on what's in the source string. ASCII and
UTF8 will be the same for all ASCII characters, but all three will be
different for non-ASCII characters.

These string->Byte() conversion issues seem to cause the most problems for
people doing cryptography work.

Joe K.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top