Re: System.Text.Encoding help ????



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" <sergecalderara@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:499438F4-C02B-4ECA-980E-D1790E58B0E7@xxxxxxxxxxxxxxxx
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


.



Relevant Pages

  • Re: How to decrypt a string?
    ... converting a string to another string. ... No. Encryption works on binary data, and it's not safe to treat ...
    (microsoft.public.dotnet.framework)
  • Re: TripleDES output size
    ... It depends on how you are converting your string data to binary (what ... you can figure out how many bytes of cipher data you'll get by ... I'm new to cryptography and I've to implement encryption of data into ...
    (microsoft.public.dotnet.security)
  • Re: Byte array to string and back - newbie question
    ... // Create a symmetric algorithm. ... This is done to make encryption more ... // Encrypt a string into a string using a password ... // Decrypt a byte array into a byte array using a key and an IV ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Using Python To Create An Encrypted Container
    ... an encrypted archive utility designed for secure archiving ... A match string allows you to only extract files matching a given ... Encrypt the string s using passwd and encryption cipher enc ...
    (comp.lang.python)
  • Re: How good an encryption algorithm is this?
    ... As long as the string can be converted to/from a byte stream, ... then you can apply that after the encryption. ... > So I decided to invent my own algorithm, and I just wanted anybody's> opinion on how secure this could be compared to the Win32 API version. ... > HCRYPTHASH hCryptHash; ...
    (microsoft.public.dotnet.languages.csharp)