J
Jeremy Kitchen
I have encoded a string into Base64 for the purpose of encryption. I
then later decrypted it and converted it back from Base64 the final
string returns with four nothing characters.
"pass" what the result should be
"pass____ what the result is where each underline char is a nothing
char.
I am about to write a function that will remove the nothing chars butI
would like to know what is causing the problem and simply avoid it
instead.
Encoding code:
Private Shared Function EncodeBase64(ByVal message As String) As
String
Dim encodeBuffer As Byte() =
System.Text.Encoding.Unicode.GetBytes(message)
Return Convert.ToBase64String(encodeBuffer)
End Function
Decoding Code:
Private Shared Function DecodeBase64(ByVal decodeBuffer As Byte()) As
String
Return System.Text.Encoding.Unicode.GetString(decodeBuffer)
End Function
I believe that the encryption is working as intended
DecodeBase64(Decrypt(password, crypto)) is the line that returns the
wrong string.
Thanks for any help
Jeremy
then later decrypted it and converted it back from Base64 the final
string returns with four nothing characters.
"pass" what the result should be
"pass____ what the result is where each underline char is a nothing
char.
I am about to write a function that will remove the nothing chars butI
would like to know what is causing the problem and simply avoid it
instead.
Encoding code:
Private Shared Function EncodeBase64(ByVal message As String) As
String
Dim encodeBuffer As Byte() =
System.Text.Encoding.Unicode.GetBytes(message)
Return Convert.ToBase64String(encodeBuffer)
End Function
Decoding Code:
Private Shared Function DecodeBase64(ByVal decodeBuffer As Byte()) As
String
Return System.Text.Encoding.Unicode.GetString(decodeBuffer)
End Function
I believe that the encryption is working as intended
DecodeBase64(Decrypt(password, crypto)) is the line that returns the
wrong string.
Thanks for any help
Jeremy