본문 바로가기
카테고리 없음

[vb.net] 암호화/복호화(Encrypt / Decrypt)

by IT HUB 2020. 9. 21.
728x90
반응형
    '// 복호화
    Public Function Decrypt(ByVal cipherText As String, Optional key As String = ""As String
        If key.Length = 0 Then key = Application.ProductName
        Dim wrapper As New Simple3Des(key)
        Try
            Return wrapper.DecryptData(cipherText)
        Catch ex As System.Security.Cryptography.CryptographicException
            'MsgBox("The data could not be decrypted with the password.")
        End Try
        Return Nothing
    End Function
 
    '// 암호화
    Public Function Encrypt(ByVal plaintext As String, Optional key As String = ""As String
        If key.Length = 0 Then key = Application.ProductName
        Dim wrapper As New Simple3Des(key)
        Dim cipherText As String = wrapper.EncryptData(plaintext)
        Return cipherText
    End Function



반응형


댓글