Home All Groups Group Topic Archive Search About

System.Text.Encoding help ????

Author
17 Jul 2006 7:35 AM
serge calderara
Dear all,

Suring studying security issue on application and cryptin/Decripting, sample
I have found use quite a lot the System.Text.Encoding class.

Then a point is mentionned that we shave to be carefull on which encoding
method is use for Decrypring and Encryprting.

What is the way to select or to know which encoding mode we should use in
general like Unicode, BASe64,Ascii .... ?

Thanks for your help
regards
Serge

Author
17 Jul 2006 1:58 PM
Joe Kaplan (MVP - ADSI)
When converting arbitrary binary data like an encryption key or hash to/from
a string, always use a method like Base64.  It is designed for use with
arbitrary binary data.

When converting a string object to binary for encryption, etc., you need to
remember that .NET strings are Unicode.  If you want to be sure that all of
the data in the string is converted to binary and back without loss, then
you should use a Unicode based encoding like UTF8 or UTF16 (called Unicode
in .NET).  UTF8 is smaller.

If you are absolutely sure your text will only be a certain character set,
then you can use that encoding.  However, why bother?  UTF8 falls back to
ASCII binary equivalence if the string only contains ASCII characters, so
why not just use UTF8?

If your input data is already binary, then leave it as such.

My $0.02,

Joe K.

--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
Show quoteHide quote
"serge calderara" <sergecalder***@discussions.microsoft.com> wrote in
message news:499438F4-C02B-4ECA-980E-D1790E58B0E7@microsoft.com...
> Dear all,
>
> Suring studying security issue on application and cryptin/Decripting,
> sample
> I have found use quite a lot the System.Text.Encoding class.
>
> Then a point is mentionned that we shave to be carefull on which encoding
> method is use for Decrypring and Encryprting.
>
> What is the way to select or to know which encoding mode we should use in
> general like Unicode, BASe64,Ascii .... ?
>
> Thanks for your help
> regards
> Serge
Author
18 Jul 2006 5:26 AM
serge calderara
Thnaks for you clarification

regards
serge

Show quoteHide quote
"Joe Kaplan (MVP - ADSI)" wrote:

> When converting arbitrary binary data like an encryption key or hash to/from
> a string, always use a method like Base64.  It is designed for use with
> arbitrary binary data.
>
> When converting a string object to binary for encryption, etc., you need to
> remember that .NET strings are Unicode.  If you want to be sure that all of
> the data in the string is converted to binary and back without loss, then
> you should use a Unicode based encoding like UTF8 or UTF16 (called Unicode
> in .NET).  UTF8 is smaller.
>
> If you are absolutely sure your text will only be a certain character set,
> then you can use that encoding.  However, why bother?  UTF8 falls back to
> ASCII binary equivalence if the string only contains ASCII characters, so
> why not just use UTF8?
>
> If your input data is already binary, then leave it as such.
>
> My $0.02,
>
> Joe K.
>
> --
> Joe Kaplan-MS MVP Directory Services Programming
> Co-author of "The .NET Developer's Guide to Directory Services Programming"
> http://www.directoryprogramming.net
> --
> "serge calderara" <sergecalder***@discussions.microsoft.com> wrote in
> message news:499438F4-C02B-4ECA-980E-D1790E58B0E7@microsoft.com...
> > Dear all,
> >
> > Suring studying security issue on application and cryptin/Decripting,
> > sample
> > I have found use quite a lot the System.Text.Encoding class.
> >
> > Then a point is mentionned that we shave to be carefull on which encoding
> > method is use for Decrypring and Encryprting.
> >
> > What is the way to select or to know which encoding mode we should use in
> > general like Unicode, BASe64,Ascii .... ?
> >
> > Thanks for your help
> > regards
> > Serge
>
>
>