Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim aes_CryptoTransform As ICryptoTransform = AesCryptoServiceProvider.Create.CreateEncryptor(aesKeySet.Key, aesKeySet.IV)
- Dim textBytes() As Byte = System.Text.Encoding.ASCII.GetBytes(rtb_plaintext.Text)
- Dim encrypted() As Byte
- using msEncrypt As New MemoryStream()
- using csEncrypt As New CryptoStream(textBytes, aes_CryptoTransform, CryptoStreamMode.write)
- using textStream as New StreamWriter(csEncrypt)
- swEncrypt.Write(plainText)
- End Using
- encrypted = msEncrypt.ToArray()
- csEncrypt.close()
- End Using
- End Using
- dim textDirectoryPath as String = "C:encryptText.text"
- using textFilestream as new Filestream(textDirectoryPath, filemode.create)
- textFilestream.write(encrypted, 0, encrypted.length)
- textFilestream.close()
- end using
- Dim aes_CryptoTransform As ICryptoTransform = AesCryptoServiceProvider.Create.CreateEncryptor(aesKeySet.Key, aesKeySet.IV)
- Dim textBytesToDecrypt() As Byte = File.readAllBytes("C:encryptText.text")
- dim plainText as string = nothing
- using msEncrypt As New MemoryStream(textBytesToDecrypt)
- using csEncrypt As New CryptoStream(textBytes, aes_CryptoTransform, CryptoStreamMode.read)
- using textStream as New StreamReader(csEncrypt)
- plainText = textStream.readToEnd()
- End Using
- csEncrypt.close()
- End Using
- End Using
Add Comment
Please, Sign In to add comment