Predicting the length of an encrypted string

I use this for encryption: http://msdn.microsoft.com/en-us/library/system.security.cryptography.rijndaelmanaged.aspx

Is there a way to predict how ciphertext will look? I convert encrypted output to text to save it in db.

I just want to make sure the database column size is large enough.

I limit text input to 20 characters.

+3
source share
4 answers

Are you using SQL Server 2005 or higher? If so, you can simply use VARCHAR(MAX)either NVARCHAR(MAX)for the column type.

If you want to be more precise ...

RijndaelManaged 256 (32 ).

- 20 , , , 4 , 80 , 96 .

Base64 , 128 96 . , 192 96 (, , , "0x" ). 200 .

(NB: " ". , !)

+10

, , , , , , , .

, , , , 1.5x - 2x.

+3

   ((length+16)/16)*16 

.

IV , 16 .

, char , . .

For base64, multiply it by 4/3. For hexadecimal, double it.

+2
source

Encryption will never increase the size of the data beyond the required minimum population.

If it "extends" the data, it is probably not a very good encryption algorithm.

0
source

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


All Articles