Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Function EncryptString(ByVal inputString As String) As String
- Dim memStream As MemoryStream = Nothing
- Try
- Dim key() As Byte = New Byte(-1) {}
- Dim IV() As Byte = New Byte() {12, 21, 43, 17, 57, 35, 67, 27}
- Dim encryptKey As String = "aXb2uy4z"
- key = Encoding.UTF8.GetBytes(encryptKey)
- Dim byteInput() As Byte = Encoding.UTF8.GetBytes(inputString)
- Dim provider As DESCryptoServiceProvider = New DESCryptoServiceProvider
- memStream = New MemoryStream
- Dim transform As ICryptoTransform = provider.CreateEncryptor(key, IV)
- Dim cryptoStream As CryptoStream = New CryptoStream(memStream, transform, CryptoStreamMode.Write)
- cryptoStream.Write(byteInput, 0, byteInput.Length)
- cryptoStream.FlushFinalBlock
- Catch ex As Exception
- Response.Write(ex.Message)
- End Try
- Return Convert.ToBase64String(memStream.ToArray)
- End Function
- Public Function EncryptString(ByVal inputString As String) As String
- Dim memStream As MemoryStream = Nothing
- Try
- Dim key() As Byte = New Byte(-1) {}
- Dim IV() As Byte = New Byte() {12, 21, 43, 17, 57, 35, 67, 27}
- Dim encryptKey As String = "aXb2uy4z"
- key = Encoding.UTF8.GetBytes(encryptKey)
- Dim byteInput() As Byte = Encoding.UTF8.GetBytes(inputString)
- Dim provider As DESCryptoServiceProvider = New DESCryptoServiceProvider
- memStream = New MemoryStream
- Dim transform As ICryptoTransform = provider.CreateEncryptor(key, IV)
- Dim cryptoStream As CryptoStream = New CryptoStream(memStream, transform, CryptoStreamMode.Write)
- cryptoStream.Write(byteInput, 0, byteInput.Length)
- cryptoStream.FlushFinalBlock
- Catch ex As Exception
- Response.Write(ex.Message)
- End Try
- Return Convert.ToBase64String(memStream.ToArray)
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement