29 lines
1.1 KiB
VB.net
29 lines
1.1 KiB
VB.net
Public Class SecurityUtils
|
|
|
|
#Region " Declarations "
|
|
|
|
Private Const ENCRYPTION_KEY_SUFFIX As String = "SDT"
|
|
#End Region
|
|
|
|
#Region " Methods "
|
|
|
|
Public Shared Function EncryptValue(value As String, key As String) As String
|
|
Dim encryption As New EncryptionUtils.SymmetricEncryptor(EncryptionUtils.SymmetricEncryptor.Provider.Rijndael)
|
|
|
|
Return encryption.Encrypt(New EncryptionUtils.Data(value), New EncryptionUtils.Data(key & ENCRYPTION_KEY_SUFFIX)).ToBase64
|
|
End Function
|
|
|
|
Public Shared Function DecryptValue(encryptedValue As String, key As String) As String
|
|
Dim encryption As New EncryptionUtils.SymmetricEncryptor(EncryptionUtils.SymmetricEncryptor.Provider.Rijndael)
|
|
|
|
' note EncryptValue returns Base64 string so we need to initialized encryptedData as Base64
|
|
Dim encryptedData As EncryptionUtils.Data = New EncryptionUtils.Data()
|
|
encryptedData.Base64 = encryptedValue
|
|
|
|
Return encryption.Decrypt(encryptedData, New EncryptionUtils.Data(key & ENCRYPTION_KEY_SUFFIX)).Text
|
|
End Function
|
|
|
|
#End Region
|
|
|
|
End Class
|