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

Sébastien Pouliot spouliot at videotron.ca
Mon Apr 4 12:02:27 EDT 2005


Hello Andrew,

IIRC Convert.FromBase64String is (or was) using
System.Security.Cryptography.FromBase64Transform.

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).

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

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

Sebastien Pouliot
home: spouliot at videotron.ca
blog: http://pages.infinit.net/ctech/poupou.html


> -----Original Message-----
> From: mono-devel-list-admin at lists.ximian.com
> [mailto:mono-devel-list-admin at lists.ximian.com]On Behalf Of Andrew Skiba
> Sent: 4 avril 2005 11:35
> To: Atsushi Eno
> Cc: mono-devel mailing list
> Subject: [Mono-devel-list] Re: CodeDom in Compiler.cs
>
>
> Atsushi Eno wrote:
> >> Yes, that's what I meant. Other similar thing is at
> >> System.Xml.Schema/BuiltInDatatype.cs:36. Does it really need
> >> System.Security.Cryptography?
> >
> > Yes. It uses FromBase64Transform.
> >
>
> I see that FromBase64Transform was inserted there at svn revision 22077.
> What was the rationale of that fix? Why is FromBase64String better than
> Convert.FromBase64String? This is the relevant part of the patch:
>
> --- System.Xml.Schema/ChangeLog (revision 22076)
> +++ System.Xml.Schema/ChangeLog (revision 22077)
> @@ -1,3 +1,15 @@
> +2004-01-14  David Sheldon <dave-mono at earth.li>
> +
> +        * BuiltInDatatype.cs:
> +          XsdBase64Binary - Added Length, and used more direct,
> less fussy,
> +              Base64 decoder.
>
> --- System.Xml.Schema/BuiltInDatatype.cs        (revision 22076)
> +++ System.Xml.Schema/BuiltInDatatype.cs        (revision 22077)
> @@ -12,6 +12,7 @@
>   using System.Xml;
>   using System.Xml.Schema;
>   using System.Globalization;
> +using System.Security.Cryptography;
>
>   namespace Mono.Xml.Schema
>   {
> @@ -1126,21 +1094,83 @@
>                  public override object ParseValue (string s,
>                          XmlNameTable nameTable,
> XmlNamespaceManager nsmgr)
>                  {
> -                       return Convert.FromBase64String (Normalize (s));
> +                       // If it isnt ASCII it isnt valid base64 data
> +                       byte[] inArr = new
> System.Text.ASCIIEncoding().GetBytes(s);
> +                       FromBase64Transform t = new FromBase64Transform();
> +                       return t.TransformFinalBlock(inArr, 0,
> inArr.Length);
>                  }
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list




More information about the Mono-devel-list mailing list