So try :
MsgBox(DecodeBase64(EncodeBase64("pass")) = "pass")
Return True here so it doesn't look like the problem is the base64
encoding/decoding part. If you try a longer word would you have always twice
the number of characters ? (unicode vs ansi problem ?).
--
Patrice
"Jeremy Kitchen" <J.*********@gmail.coma écrit dans le message de news:
11**********************@l75g2000hse.googlegroups. com...
On Mar 23, 9:45 am, "Patrice" <http://www.chez.com/scribe/wrote:
Also I find a bit weird that you actually see something that is almost the
original string. Base64 should produce a much more different string.
That plus the fact that the encoding function returns a string and that
the
decoding function accept a buffer would make me think that you perhaps
still
have a problem between those two functions calls...
---
Patrice
"Patrice" <http://www.chez.com/scribe/a écrit dans le message de news:
uMsCekVbHHA.4...@TK2MSFTNGP05.phx.gbl...
DecodeBase64 does nothing ? You probably forgot to a call to the
appropriate FromBase64 method...
---
Patrice
"Jeremy Kitchen" <J.t.Kitc...@gmail.coma écrit dans le message de
news:
1174658205.018099.79...@l77g2000hsb.googlegroups.c om...
>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(decodeBuffe r)
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
I also have an overload of the Decode that accepts a string.
Here both decode functions are.
Private Shared Function DecodeBase64(ByVal message As String) As
String
Dim decodeBuffer As Byte() = Convert.FromBase64String(message)
Return DecodeBase64(decodeBuffer)
End Function
Private Shared Function DecodeBase64(ByVal decodeBuffer As Byte()) As
String
Return
CleanStringOfNothings(System.Text.Encoding.Unicode .GetString(decodeBuffer))
End Function