[Mono-devel-list] Re: CodeDom in Compiler.cs

Andrew Skiba andrews at mainsoft.com
Tue Apr 5 12:10:35 EDT 2005


Sébastien Pouliot wrote:
 > Hello Andrew,
 >
 > IIRC Convert.FromBase64String is (or was) using
 > System.Security.Cryptography.FromBase64Transform.

Yes, it is. But it has a comment, saying "the BASE64 convert methods are
using the Base64 converting methods from
System.Security.Cryptography.ToBase64Transform and
System.Security.Cryptography.FromBase64Transform. Should be changed to a
stand-alone class Base64Encoder & Base64Decoder"

The waste here is to perform additional pass to convert string containing
base64 characters into byte []. The whole convert can be done in a
single pass, in principle.

 > However there was a few difference between them (non bas64 characters
 > accepted/refused).
 > I would _guess_ that using directly the transform was
 > better (performance wise) as it didn't need to call 
Convert.FromBase64String
 > (with it own extra logic) and the Normalize method on the string (which
 > probably did the reverse of the extra stuff Convert.FromBase64String was
 > doing).

It looks that Normalizer was unnecessary anyway. All it does is changes
between different kinds of whitespace, and whitespace is anyway ignored
in Convert.FromBase64String.

The whole problem is that functionality needed here is exactly covered
by Convert.FromBase64String function. But because this function was not
implemented well, David changed the code to use S.S.C. I think, we 
should fix FromBase64String, so every place that uses this function will 
benefit. grep finds 62 places like that, and 19 places with 
FromBase64CharArray.

 > I'm curious what's the problem of including 
System.Security.Cryptography ?

No, there is no problem with that.

 > As anyway Convert.FromBase64String won't work if S.S.C isn't available?

We have this function implemented in Java.

Andrew Skiba.



More information about the Mono-devel-list mailing list