Re: Base64 question
Thanks. That's similar to what I have written. I'll see if I can get mine to
perform better. I was using a StringBuilder to accept the encoded
characters. I'll see if it performs better using a character array, and save
the string construction until it's complete.
"Jon Skeet [C# MVP]" <skeet@pobox.co mwrote in message
news:MPG.20fa97 25cf46dc4e2bd@m snews.microsoft .com...
Arne Vajhøj <arne@vajhoej.d kwrote:
Depending on the exact context, it can be handy to get rid of / and =
too. In some cases it's just + that needs to be replaced though, yes.
Indeed... possibly with a check to see whether a replacement is needed
to start with.
>
Base64 is a standard. It is not common to allow mocking with a standard.
I think it's pretty common to adapt base64 to only include URL-safe
characters. Put it this way - it's common enough to have made it into
Wikipedia:
--
Jon Skeet - <skeet@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Thanks. That's similar to what I have written. I'll see if I can get mine to
perform better. I was using a StringBuilder to accept the encoded
characters. I'll see if it performs better using a character array, and save
the string construction until it's complete.
"Jon Skeet [C# MVP]" <skeet@pobox.co mwrote in message
news:MPG.20fa97 25cf46dc4e2bd@m snews.microsoft .com...
Arne Vajhøj <arne@vajhoej.d kwrote:
Jim Brandley wrote:
>
I believe that + is the only non URL valid character in base64 output.
I need to append a short ciphertext string as a query variable encoded
so
it's valid for a URL. After encryption, I convert the bytes to Base64.
However, the result includes characters that are invalid for a URL,
notably
'+' symbols. So, I have to cycle the output string through
HttpUtility.Url Encode(). That takes time. I wrote my own URL-safe Base64
converter in C#, that's about as lean as I can make it. It is much
slower
(about 6 times) than the the one provided. However, it runs in about 70%
of
the time required to use the standard Base64 converter followed by a
trip
through UrlEncode().
so
it's valid for a URL. After encryption, I convert the bytes to Base64.
However, the result includes characters that are invalid for a URL,
notably
'+' symbols. So, I have to cycle the output string through
HttpUtility.Url Encode(). That takes time. I wrote my own URL-safe Base64
converter in C#, that's about as lean as I can make it. It is much
slower
(about 6 times) than the the one provided. However, it runs in about 70%
of
the time required to use the standard Base64 converter followed by a
trip
through UrlEncode().
I believe that + is the only non URL valid character in base64 output.
too. In some cases it's just + that needs to be replaced though, yes.
Why not a simple String Replace ?
to start with.
I am using .Net 2.0, and I have not found a way to coerce the built in
Base64 converter to use a character set that could avoid the trip
through
UrlEncode. Am I missing anything? If not, is there any way to add this
capability to a future release?
Base64 converter to use a character set that could avoid the trip
through
UrlEncode. Am I missing anything? If not, is there any way to add this
capability to a future release?
Base64 is a standard. It is not common to allow mocking with a standard.
characters. Put it this way - it's common enough to have made it into
Wikipedia:
--
Jon Skeet - <skeet@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Comment