'在表單
Dim S As String = TextBox1.Text
Dim EncodedString As String = ToBase64(System.Text.Encoding.UTF8.GetBytes(S))
Dim DecodedString As String = System.Text.Encoding.UTF8.GetString(FromBase64(EncodedString))
'在模組
Public Function ToBase64(ByVal data() As Byte) As String
If data Is Nothing Then Throw New ArgumentNullException("data")
Return Convert.ToBase64String(data)
End Function
Public Function FromBase64(ByVal base64 As String) As Byte()
If base64 Is Nothing Then Throw New ArgumentNullException("base64")
Return Convert.FromBase64String(base64)
End Function
沒有留言:
張貼留言