Thread: new KeyGenMe
View Single Post
  #8  
Old 09-10-2013, 13:16
giv's Avatar
giv giv is offline
VIP
 
Join Date: Jan 2011
Location: Romania
Posts: 1,663
Rept. Given: 803
Rept. Rcvd 1,283 Times in 561 Posts
Thanks Given: 228
Thanks Rcvd at 567 Times in 241 Posts
giv Reputation: 1100-1299 giv Reputation: 1100-1299 giv Reputation: 1100-1299 giv Reputation: 1100-1299 giv Reputation: 1100-1299 giv Reputation: 1100-1299 giv Reputation: 1100-1299 giv Reputation: 1100-1299 giv Reputation: 1100-1299
Quote:
Originally Posted by LordCoder View Post
@GIV SHA256 difficult in VB.NET?
Thank you!
But i have one small question:
From Keygener Assistant 2.1.0 the output from string:
Quote:
giv
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
Reply With Quote
The Following User Gave Reputation+1 to giv For This Useful Post: