Solved

vb.net Decode a SHA1 hash

Posted on 2009-04-07
4
3,516 Views
Last Modified: 2012-05-06
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
Comment
Question by:sgaggerj
  • 2
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
OBonio earned 500 total points
ID: 24088432
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
 
LVL 1

Author Comment

by:sgaggerj
ID: 24088690
that's what i figured....
0
 
LVL 8

Expert Comment

by:OBonio
ID: 24094892
If you're trying to unhash, you could look up rainbow tables....
0
 
LVL 1

Author Comment

by:sgaggerj
ID: 24097591
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

You cannot be 100% sure that you can protect your organization against crypto ransomware but you can lower down the risk and impact of the infection.
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

939 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now