Link to home
Start Free TrialLog in
Avatar of sgaggerj
sgaggerjFlag for United States of America

asked on

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

ASKER CERTIFIED SOLUTION
Avatar of OBonio
OBonio
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sgaggerj

ASKER

that's what i figured....
If you're trying to unhash, you could look up rainbow tables....
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!