C
Cole Shelton
Hi all,
I am simply trying to do a transform to a base 64 string and back, but for
some reason, the FromBase64Transform is return less bytes than it should. I
have verified that the base64 string is the same length as the one that was
output from ToBase64Transform. I also turned on DoNotIgnoreWhitespaces.
Any ideas?? Here is the code:
// ToBase64
ASCIIEncoding enc = new ASCIIEncoding();
byte[] valBytes = enc.GetBytes(val);
MemoryStream mstr = new MemoryStream();
CryptoStream str = new CryptoStream(mstr,new
ToBase64Transform(),CryptoStreamMode.Write);
str.Write(valBytes,0,valBytes.Length);
byte[] buf = mstr.ToArray();
return Convert.ToBase64String(buf);
// From Base64
byte[] valBytes = Convert.FromBase64String(val);
MemoryStream mstr = new MemoryStream();
CryptoStream str = new CryptoStream(mstr,new
FromBase64Transform(FromBase64TransformMode.DoNotIgnoreWhiteSpaces),CryptoSt
reamMode.Write);
str.Write(valBytes,0,valBytes.Length);
byte[] buf = mstr.ToArray();
ASCIIEncoding enc = new ASCIIEncoding();
return enc.GetString(buf);
I am simply trying to do a transform to a base 64 string and back, but for
some reason, the FromBase64Transform is return less bytes than it should. I
have verified that the base64 string is the same length as the one that was
output from ToBase64Transform. I also turned on DoNotIgnoreWhitespaces.
Any ideas?? Here is the code:
// ToBase64
ASCIIEncoding enc = new ASCIIEncoding();
byte[] valBytes = enc.GetBytes(val);
MemoryStream mstr = new MemoryStream();
CryptoStream str = new CryptoStream(mstr,new
ToBase64Transform(),CryptoStreamMode.Write);
str.Write(valBytes,0,valBytes.Length);
byte[] buf = mstr.ToArray();
return Convert.ToBase64String(buf);
// From Base64
byte[] valBytes = Convert.FromBase64String(val);
MemoryStream mstr = new MemoryStream();
CryptoStream str = new CryptoStream(mstr,new
FromBase64Transform(FromBase64TransformMode.DoNotIgnoreWhiteSpaces),CryptoSt
reamMode.Write);
str.Write(valBytes,0,valBytes.Length);
byte[] buf = mstr.ToArray();
ASCIIEncoding enc = new ASCIIEncoding();
return enc.GetString(buf);