35 lines
1.1 KiB
VB.net
35 lines
1.1 KiB
VB.net
Imports System.Configuration
|
|
Imports System.Security.Cryptography
|
|
Imports System.Text
|
|
Imports Strata.Configuration.Client.Models.Jazz
|
|
|
|
Namespace Encryptors
|
|
|
|
Public Class UserSaltEncryptionMethod
|
|
Implements IPasswordEncryptionMethod
|
|
|
|
#Region " Declarations "
|
|
|
|
Private Const NUMBER_ITERATIONS As Integer = 100000
|
|
|
|
#End Region
|
|
|
|
#Region " Methods "
|
|
|
|
Public Function Encode(ByVal username As String, ByVal anOrgPin As String, ByVal aNewPassword As String, ByVal aUserGUID As System.Guid, aSalt As String) As String Implements IPasswordEncryptionMethod.Encode
|
|
Dim saltAndPepper As String = aSalt & ConfigurationManager.AppSettings(NameOf(StrataJazzOptions.UserSaltEncryptionKey))
|
|
|
|
Using deriveBytes As Rfc2898DeriveBytes = New Rfc2898DeriveBytes(aNewPassword, Encoding.UTF8.GetBytes(saltAndPepper), NUMBER_ITERATIONS, HashAlgorithmName.SHA256)
|
|
Dim password As Byte() = deriveBytes.GetBytes(24)
|
|
|
|
Return Convert.ToBase64String(password)
|
|
End Using
|
|
End Function
|
|
|
|
|
|
#End Region
|
|
|
|
End Class
|
|
|
|
End Namespace
|