mancode1007 0 Newbie Poster

Guys, I having problem with the encryption method. I have the class but not quite understand. It will store the salt and hash password in the database.

Imports Microsoft.VisualBasic
Imports System.Security.Cryptography
Imports System.Text

Public Class PasswordCrypto
   Private Hasher As New SHA1CryptoServiceProvider()

   Public Function GetSalt(ByVal saltSize As Integer) As String
       Dim buffer() As Byte = New Byte(saltSize) {}
       Dim rng As New RNGCryptoServiceProvider()

       rng.GetBytes(buffer)
       Return Convert.ToBase64String(buffer)
   End Function


   Public Function HashEncryptString(ByVal s As String) As String
       Dim clearBytes As Byte() = Encoding.UTF8.GetBytes(s)
       Dim hashedBytes As Byte() = Hasher.ComputeHash(clearBytes)

       Return Convert.ToBase64String(hashedBytes)
   End Function


   Public Function HashEncryptStringWithSalt(ByVal s As String, ByVal salt As String) As String
       Return HashEncryptString(salt + s)
   End Function
End Class

Please help.Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.