MS Encryption
This commit is contained in:
24
EnvelopeGenerator.Form/Helper/Encryption.vb
Normal file
24
EnvelopeGenerator.Form/Helper/Encryption.vb
Normal file
@@ -0,0 +1,24 @@
|
||||
Imports System.Security.Cryptography
|
||||
Imports System.Text
|
||||
|
||||
Public Class Decryption
|
||||
|
||||
Private Shared key As String = "$xzBvyPETUS&amm8)D8x#)f;4%;?[BPd" ' Passwort-Schlüssel (16, 24, or 32 bytes)
|
||||
Private Shared iv As String = "1wN&e[zrQ6_B7X/0" ' Initialisierungsvektor (16 bytes)
|
||||
|
||||
|
||||
' Entschlüsselungsfunktion
|
||||
Public Shared Function Decrypt(cipherText As String) As String
|
||||
Dim aesAlg As Aes = Aes.Create()
|
||||
aesAlg.Key = Encoding.UTF8.GetBytes(key)
|
||||
aesAlg.IV = Encoding.UTF8.GetBytes(iv)
|
||||
Dim decryptor As ICryptoTransform = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV)
|
||||
Dim cipherBytes As Byte() = Convert.FromBase64String(cipherText)
|
||||
Dim msDecrypt As New IO.MemoryStream(cipherBytes)
|
||||
Using csDecrypt As New CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read)
|
||||
Using srDecrypt As New IO.StreamReader(csDecrypt)
|
||||
Return srDecrypt.ReadToEnd()
|
||||
End Using
|
||||
End Using
|
||||
End Function
|
||||
End Class
|
||||
Reference in New Issue
Block a user