[Mono-list] Encryption in CSharp and Mono?
atsushi at ximian.com
Thu Feb 15 13:49:36 EST 2007
Small followup: sometimes people use Encoding.UTF8 (or even worse,
Encoding.ASCII) to convert byte arrays and strings. It is not safe
since there are invalid byte sequences and/or character sequences
that cannot be converted to the destination type in both ways.
Convert.[From|To]Base64String() are correct solutions.
Sebastien Pouliot wrote:
> On Thu, 2007-02-15 at 19:11 +0100, Stojance Dimitrovski wrote:
>> I need to encrypt a string with quite a strong encryption, but the
>> output needs to be a UTF8 encoded string.
> Encryption works on bytes (in and out).
> However it's easy to convert a string into a byte array (input), encrypt
> it and the convert the (encrypted byte array) into a base64 string
> (which is a valid UTF8 string).
> There are variations but trying to be simpler than that (3 steps) will
> only cause you pain.
>> I've been googling for it and there are some examples that show up but
>> I am just not sure enogh for them.
>> I kinda remember about .NET having something like System.Cryptography
> Sure you used Google ?
> The namespace is System.Security.Cryptography. However you won't find a
> class that deals with strings in it. The conversion (string/bytes) can
> be done using System.Convert class and using the encoding classes in the
> System.Text namespace.
>> Mono-list maillist - Mono-list at lists.ximian.com
> Mono-list maillist - Mono-list at lists.ximian.com
More information about the Mono-list