Link to home
Start Free TrialLog in
Avatar of aborg85
aborg85

asked on

Encryption SHA256

Hi Everyone,

        I need to encrypt the password entered by the user. Does anyone know the code for SHA256?? please keep it as simple as possible. What i was able to find on the internet is this:

    Protected Shared Function SHA256_Encrypt(ByVal Txt As String) As String

        Dim sha As New SHA256Managed()
        Dim ae As New ASCIIEncoding()
        Dim Hash() As Byte = sha.ComputeHash(ae.GetBytes(Txt))
        Dim sb As New StringBuilder(Hash.Length * 2)
        Dim ndx As Integer

        For ndx = 0 To Hash.Length - 1
            sb.Append(Right("0" & Hex(Hash(ndx)), 2)) <----- the word right not being accepted
        Next

        Return sb.ToString

    End Function

Now for some reason the word right is not being accepted and when i go over the word it tells me: "Cannot refer to an instance member of a class from within a shared method or shared method initilizer without an explict instance of the class"

this was taken from:

http://www.thescripts.com/forum/thread384017.html

Any ideas???

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of jrscherer
jrscherer
Flag of United States of America 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 aborg85
aborg85

ASKER

Thanks Jack.net