Quote:
Originally Posted by LordCoder
@GIV SHA256 difficult in VB.NET?
|
Thank you!
But i have one small question:
From Keygener Assistant 2.1.0 the output from string:
is:
Quote:
|
BCAEFCCB60B768211C31AA80377915B6FAF959638088FEE5A0FDC516B156768F
|
And if i parse the name trough your function the output will be:
Quote:
|
7804AAB331F6D12650165EFDA268173DC5A2E6A6A8067DD2807FB9D6A82420F0
|
Why the outputs are being diferent?
Here is the code i have implemented:
Quote:
Imports System.Text
Imports System.Security.Cryptography
Public Class Form1
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim t1 As String = TextBox1.Text
Dim t2 As String = EncryptSHA256Managed(t1)
t2 = t2.ToUpper
t2 = Replace(t2, " ", "")
TextBox2.Text = t2
End Sub
Public Function EncryptSHA256Managed(ByVal ClearString As String) As String
Dim uEncode As New UnicodeEncoding()
Dim bytClearString() As Byte = uEncode.GetBytes(ClearString)
Dim sha As New _
System.Security.Cryptography.SHA256Managed()
Dim hash() As Byte = sha.ComputeHash(bytClearString)
Dim sBuilder As New StringBuilder
For Each b As Byte In hash
sBuilder.AppendFormat("{0:x2} ", b)
Next
Return sBuilder.ToString()
End Function
End Class
|