R
Rohan Danushka
Guest
HI,
I'm try to create text login project with encrypted passwords. this project was work prefetly before and now it's not working with user login part. but, i can add user it's working same as before. when i try to login this is the final event shows as output. after this nothing happen with login
Screen Shot:
My Code in Form:
Dim username As String = TextBox1.Text
Dim password = Encryption.HashString(TextBox2.Text)
Dim salt = Encryption.GenarateSalt
Dim hashedAndSalted = Encryption.HashString(String.Format("{0}{1}", password, salt))
DBManager.Login(TextBox1.Text, TextBox2.Text)
Code in Class:
Private ReadOnly CryotiServiceProvider As Security.Cryptography.RNGCryptoServiceProvider
Public Shared Function HashString(str As String) As String
Return EncryptString(str)
End Function
Public Shared Function GenarateSalt() As String
Using cryptoServiceProvider As New Security.Cryptography.RNGCryptoServiceProvider
Dim StrBuilder As New Text.StringBuilder
Dim data As Byte() = New Byte(4) {}
For i = 0 To 6
cryptoServiceProvider.GetBytes(data)
Dim value As String = BitConverter.ToString(data, 0)
StrBuilder.Append(value)
Next
Return EncryptString(StrBuilder.ToString())
End Using
End Function
Private Shared Function EncryptString(str As String) As String
Dim bytes As Byte() = Text.Encoding.ASCII.GetBytes(str)
Dim hashed = Security.Cryptography.SHA256.Create().ComputeHash(bytes)
Return Convert.ToBase64String(hashed)
End Function
Note: there is SQLite.Interop.dll included in both 64x and 89x folders in debug
Thank you....
RohanD
Continue reading...
I'm try to create text login project with encrypted passwords. this project was work prefetly before and now it's not working with user login part. but, i can add user it's working same as before. when i try to login this is the final event shows as output. after this nothing happen with login
Screen Shot:
My Code in Form:
Dim username As String = TextBox1.Text
Dim password = Encryption.HashString(TextBox2.Text)
Dim salt = Encryption.GenarateSalt
Dim hashedAndSalted = Encryption.HashString(String.Format("{0}{1}", password, salt))
DBManager.Login(TextBox1.Text, TextBox2.Text)
Code in Class:
Private ReadOnly CryotiServiceProvider As Security.Cryptography.RNGCryptoServiceProvider
Public Shared Function HashString(str As String) As String
Return EncryptString(str)
End Function
Public Shared Function GenarateSalt() As String
Using cryptoServiceProvider As New Security.Cryptography.RNGCryptoServiceProvider
Dim StrBuilder As New Text.StringBuilder
Dim data As Byte() = New Byte(4) {}
For i = 0 To 6
cryptoServiceProvider.GetBytes(data)
Dim value As String = BitConverter.ToString(data, 0)
StrBuilder.Append(value)
Next
Return EncryptString(StrBuilder.ToString())
End Using
End Function
Private Shared Function EncryptString(str As String) As String
Dim bytes As Byte() = Text.Encoding.ASCII.GetBytes(str)
Dim hashed = Security.Cryptography.SHA256.Create().ComputeHash(bytes)
Return Convert.ToBase64String(hashed)
End Function
Note: there is SQLite.Interop.dll included in both 64x and 89x folders in debug
Thank you....
RohanD
Continue reading...