lundi 7 novembre 2016

Generate Random 7 Bytes and Encrypt Them, Getting 8 Byte Result

I need to generate seven random bytes, then encrypt them. The encrypted result needs to be eight bytes long. The following line of code does exactly that:

openssl rand 7 | openssl enc -des3 -nosalt -k $myPassword

However, I need to store the random seven bytes for later use. If I do the following:

echo -n $mySevenRandomBytes | openssl enc -des3 -nosalt -k $myPassword

The encrypted result is anywhere from 24 bytes long to over a hundred. Does anyone know why passing "openssl rand 7" directly into the "openssl enc" always returns exactly eight bytes, while storing "openssl rand 7" in a variable, then passing that variable to "openssl enc" returns far more?

Any help would be greatly appreciated. Thank you!




Aucun commentaire:

Enregistrer un commentaire