[英]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.