?
Solved

Encryption SHA256

Posted on 2006-05-05
2
Medium Priority
?
301 Views
Last Modified: 2010-04-23
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!
0
Comment
Question by:aborg85
2 Comments
 
LVL 9

Accepted Solution

by:
jrscherer earned 2000 total points
ID: 16617699
aborg85

Your problem has nothing to do with encryption. It is a visual basic legacy problem.

Right is used by the property Forms.Right in the namespace System.Forms and is therefore called by default.

Use following namespace: Microsoft.Visualbasic.Right

sb.Append(Microsoft.VisualBasic.Right("0" & Hex(Hash(ndx)), 2)) ' <----- the word right not being accepted

The rest orf your function is working fine.

Jack.net
0
 

Author Comment

by:aborg85
ID: 16618685
Thanks Jack.net
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.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Loops Section Overview
Suggested Courses

840 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