[英]Using ByVal data As Byte()) TextBox
當我執行Secure(TextBox1.Text)
它會出錯。 我該如何解決這個錯誤? 我想加密 TextBox 數據。
錯誤:字符串值無法轉換為 BYTE 錯誤
Function Secure(ByVal data As Byte()) As Byte()
Using SA As New System.Security.Cryptography.RijndaelManaged
SA.IV = New Byte() {1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7}
SA.Key = New Byte() {7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1}
Return SA.CreateEncryptor.TransformFinalBlock(data, 0, data.Length)
End Using
End Function
Function UnSecure(ByVal data As Byte()) As Byte()
Using SA As New System.Security.Cryptography.RijndaelManaged
SA.IV = New Byte() {1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7}
SA.Key = New Byte() {7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1}
Return SA.CreateEncryptor.TransformFinalBlock(data, 0, data.Length)
End Using
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
OpenFileDialog1.DefaultExt = "exe"
OpenFileDialog1.Filter = "exe dosyaları (*.exe)|*.exe"
OpenFileDialog1.FilterIndex = 1
If OpenFileDialog1.ShowDialog(Me) = DialogResult.OK Then
TextBox1.Text = String.Empty
TextBox1.Text = OpenFileDialog1.FileName
Secure(TextBox1.Text)
End If
End Sub
End Class
替換這個:
Secure(TextBox1.Text)
和:
Secure(System.Text.Encoding.ASCII.GetBytes(TextBox1.Text))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.