Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does an encrypted byte array have a different length from its char[] representation?

Tags:

c#

encryption

I was working on some encryption/decryption algorithms and I noticed that the encrypted byte[] arrays always had a length of 33, and the char[] arrays always had a length of 44. Does anyone know why this is?

(I'm using Rijndael encryption.)

like image 719
devlord Avatar asked May 22 '26 06:05

devlord


1 Answers

Padding and text encoding. Most encryption algorithms have a block size, and input needs to be padded up to a multiple of that block size. Also, turning binary data into text usually involves the Base64 algorithm, which expands 3 bytes into 4 characters.

like image 113
Jeffrey Hantin Avatar answered May 24 '26 20:05

Jeffrey Hantin