Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > Asp.net SHA256 problem

Reply
Thread Tools

Asp.net SHA256 problem

 
 
atakan
Guest
Posts: n/a
 
      11-04-2003
Hi

I'm trying to hash a password by using SHA256Managed but it returns wrong
hash.

for "123123" the SHA256 must return
"96cae35ce8a9b0244178bf28e4966c2ce1b8385723a96a6b8 38858cdd6ca0a1e" but it
returns
"eUFcNsFFljNAhC8b5OnauOs0o0txyAUB/b0QTmDRTN0="

Why this difference occurs in SHA256Managed namespace ?

the code I used is below

Dim txtPass As String
Dim HashValue() As Byte
Dim UE As New System.Text.UnicodeEncoding
Dim ContentBytes As Byte()
Dim oSHA As New SHA256Managed
ContentBytes = UE.GetBytes(txtPassword.Text.ToString)
HashValue = oSHA.ComputeHash(ContentBytes)
txtPass = Convert.ToBase64String(HashValue)

regards
Atakan


 
Reply With Quote
 
 
 
 
atakan
Guest
Posts: n/a
 
      11-05-2003
In microsoft.public.tr.dotnet group Cenk Iscan has solved the problem.
To use SHA256 you can use following sample

Dim txtPass As String
Dim HashValue() As Byte
Dim UE As New System.Text.UTF7Encoding
Dim ContentBytes As Byte()
Dim oSHA As New SHA256Managed
ContentBytes = UE.GetBytes("123123")
HashValue = oSHA.ComputeHash(ContentBytes)
For Each chars As Byte In HashValue
If Len(Hex(chars).ToString) = 1 Then
txtPass &= "0" & Hex(chars).ToString
Else
txtPass &= Hex(chars).ToString
End If
Next
txtPass = LCase$(txtPass).ToString

regards
Atakan

"atakan" <atakane!!!!@!!!!myrealbox.com> wrote in message
news:...


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need some help confirming transactions using sha256 kryptox.exchange@gmail.com Python 3 01-31-2013 06:44 PM
sha256 Himanshu Bharti C++ 2 02-27-2012 07:48 AM
Unsupported digest algorithm (sha256). yf kuanfai Ruby 9 01-27-2011 04:00 AM
using methods base64 module in conjunction with Crypto.Hash.SHA256 mirandacascade@yahoo.com Python 1 12-20-2006 08:53 PM
SHA256 C# vs FIPS 180 Ravi Singh (UCSD) ASP .Net Security 1 01-27-2005 02:31 AM



Advertisments