What encryption should be used in coding and how does it affect key and initialization vectors?

I use encryption and how encoding affects the generation of keys and initialization vectors.

I am working with TripleDESCryptoServiceProvider , which requires a 24-byte key and an 8-byte initialization vector using ASCII encoding. If I decide to use a different encoding, how will this affect the key generation and initialization vector?

What encoding should I use instead of UTF8 / 16/32?

thanks

+4
source share
2 answers

Encryption options are completely independent of your choice of encoding. Encryption options are always specified in bytes. Encoding involves translating characters into bytes and bytes back into characters. The only place they “collide” is to use passwords to generate encryption keys. You should use a class specifically designed for this, such as Rfc2898DeriveBytes .

In most cases, when I use ASCII encoding, it would be better for the programmer to use using UTF8 encoding. UTF8 encoding encodes and decodes ASCII characters in the same way as ASCII encoding, but also correctly and efficiently encodes the rest of Unicode. Use ASCII encoding if you need to throw an exception if a non-ASCII character is encountered.

+2
source

I am not an expert, but TripleDES is no longer considered safe enough. Microsoft's recommendation is to use AES 256 bit and higher. I do not think that the encoding of the text affects the strength of the encryption, only the key length of the "plain text" and IV.

0
source

Source: https://habr.com/ru/post/1315186/


All Articles