• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3665
  • Last Modified:

vb.net Decode a SHA1 hash

I am using the function below to create an SHA1 hash of a username & password

now, given the username and the hash, how can i recover the password?

Private Function CreateHash(ByVal user As String, ByVal pass As String) As String
        Dim hashAlg As SHA1 = SHA1.Create
        Dim hashvalue() As Byte = hashAlg.ComputeHash(System.Text.Encoding.Default.GetBytes(UCase(user) & ":" & UCase(pass)))
        Dim hashstring As String = ""
        For Each b As Byte In hashvalue
            hashstring += b.ToString("x2")
        Next
        hashAlg = Nothing
        hashvalue = Nothing
        Return hashstring
    End Function

Open in new window

0
sgaggerj
Asked:
sgaggerj
  • 2
  • 2
1 Solution
 
OBonioCommented:
A hash is not asymmetric which means it is one way.  Once hashed, you can't, in theory, 'unhash'.  You use hashes by comparing.  ie, input data is hashed and compared to previously computed hashes.
0
 
sgaggerjAuthor Commented:
that's what i figured....
0
 
OBonioCommented:
If you're trying to unhash, you could look up rainbow tables....
0
 
sgaggerjAuthor Commented:
Took a look and it seems a lot more time consuming that I want to spend (cpu cycle wise) on doing what i wanted.
I found a workaround.

Essentially i had a login w/ a 'remember me' box that saved the login info - but when the app is updated the settings get overwritten and the user needs to type in the login/pass again.

i added a field to my db table with the user/pass hash and store that locally instead in a separate file that never gets written over. more secure and gets the job done.

thanks!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now