Ask a Question related to ASP.NET Security, Design and Development.
-
Linda #1
sha1 problem
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
----------------------------------------------------------------------------
--------
example: If I use a text value of "a"
Run value in .net is: 0a04b971b03da607ce6c455184037b660ca89f78
compared to a hash calulator: 86f7e437faa5a7fce15d1ddcb9eaeaea377667b8
----------------------------------------------------------------------------
-----------------------------------
any ideas what is wrong here?
Linda Guest
-
Digest::SHA1 b64digest weirdness
This is really bizzaro. Here's my code: use Digest::SHA1; $password = "garbage"; my $ctx = Digest::SHA1->new; $ctx->add($password); my... -
Javascript::SHA1 V 1.01
The pure Perl module Javascript::SHA1 V 1.01 is available immediately from CPAN, and from http://savage.net.au/Perl-modules.html. On-line docs,... -
SHA1 digest
Dear all, I used Digest::SHA1 module to produce a digest on a message. The digest I get by calling sha1($msg) is a binary data in 20 bytes long.... -
Decrypt string encrypted with SHA1
No, it is not possible. SHA1 is a hashing algorithm and as any other hashing algorithm (e.g. MD5, SHA-256, etc) it does not support decryption. ... -
md5 / sha1 - Any real difference?
Folks, I use md5 hash with some of my cookies and occassionally a hidden form field - I know the physical data on my network is insecure (unless... -
Joe Kaplan \(MVP - ADSI\) #2
Re: sha1 problem
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.
"Linda" <lindan@analyticinnovations.com> wrote in message
news:uajwIkrtEHA.3628@tk2msftngp13.phx.gbl...> 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
> ----------------------------------------------------------------------------
> --------
> example: If I use a text value of "a"
> Run value in .net is: 0a04b971b03da607ce6c455184037b660ca89f78
> compared to a hash calulator: 86f7e437faa5a7fce15d1ddcb9eaeaea377667b8
> ----------------------------------------------------------------------------
> -----------------------------------
> any ideas what is wrong here?
>
>
Joe Kaplan \(MVP - ADSI\) Guest



Reply With Quote

