Asp.net SHA256 problem

Discussion in 'ASP .Net Security' started by atakan, Nov 4, 2003.

  1. atakan

    atakan Guest

    Hi

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

    for "123123" the SHA256 must return
    "96cae35ce8a9b0244178bf28e4966c2ce1b8385723a96a6b838858cdd6ca0a1e" 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
    atakan, Nov 4, 2003
    #1
    1. Advertising

  2. atakan

    atakan Guest

    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:...
    atakan, Nov 5, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    413
    Klaas
    Dec 20, 2006
  2. Ravi Singh (UCSD)

    SHA256 C# vs FIPS 180

    Ravi Singh (UCSD), Jan 26, 2005, in forum: ASP .Net Security
    Replies:
    1
    Views:
    219
    Joe Kaplan \(MVP - ADSI\)
    Jan 27, 2005
  3. yf kuanfai
    Replies:
    9
    Views:
    301
    yf kuanfai
    Jan 27, 2011
  4. Himanshu Bharti

    sha256

    Himanshu Bharti, Feb 27, 2012, in forum: C++
    Replies:
    2
    Views:
    423
    Miles Bader
    Feb 27, 2012
  5. Replies:
    3
    Views:
    143
Loading...

Share This Page