Re: Base64 question

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I'll try that and see what it costs. I was hoping to avoid another iteration
through the characters in the string.

"Arne Vajhøj" <arne@xxxxxxxxxx> wrote in message
news:46904a3e$0$90266$14726298@xxxxxxxxxxxxxxxxxx
Jim Brandley wrote:
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.UrlEncode(). 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.

Why not a simple String Replace ?

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 is a standard. It is not common to allow mocking with a standard.

Arne


.



Relevant Pages

  • Re: Compress ASCII text as Hex?
    ... There an encoding format code BASE64 (also known as UUEncoding in some ... It take fully binary data and converts it a set of 64 ... characters, so encoded blocks increase 33% in size. ... as long as your "encoded" string meets ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Base64 question
    ... I convert the bytes to Base64. ... However, the result includes characters that are invalid for a URL, ... I have to cycle the output string through ... I think it's pretty common to adapt base64 to only include URL-safe ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Please help rescue me from my ignorance. ;)
    ... > expected a call to method1to return an 'n' length string. ... Base64 encoding are always 4/3 * size of original data, ... characters) this isn't the best way of doing it. ...
    (microsoft.public.dotnet.general)
  • Re: [Q] How to eval an EXPR once and make it stick
    ... > Does the entire string, from start to end, consist of zero or more 'space' ... but I like to avoid possible boundary conditions that make me think ... Do you Yahoo!? ...
    (perl.beginners)
  • Re: Simple encryption decryption ?
    ... > But I don't understand the base64 thing. ... As I have said in my previous reply, the '=' characters are used to pad the ... base64 encoded string. ... Since the padding characters will be ignored during decoding, ...
    (alt.php)