OpenSSL: Symmetric Encryption Algorithms & Examples
Symmetric Encryption Algorithms with OpenSSL
Encrypt the file “fichero.txt” using the RC4 symmetric encryption algorithm
OpenSSL> rc4 -in c:\cifrado\fichero.txt -out c:\cifrado\cifrado.rc4enter rc4 encryption password:
Verifying - enter rc4 encryption password:Decrypt the previous file:
OpenSSL> rc4 -d -in c:\cifrado\cifrado.rc4 -out c:\cifrado\descifrado.txtenter rc4 decrypt password:DES
Encrypt:
OpenSSL> des -salt -in c:\csb.log -out c:\csb.bf.txtenter des-cbc encryption password:Verifying - enter des-cbc encryption password:Decrypt:
OpenSSL> des -d -in c:\csb.bf.txt -out c:\csb.txtenter des-cbc decryption password:Triple DES (DES3)
OpenSSL>enc -des3 -salt -in c:\cifrado\fichero.txt -out c:\cifrado\ficherocif.bin
enter des-ede3-cbc encryption password:
Verifying - enter des-ede3-cbc encryption password:OpenSSL>enc -des-ede3-cbc -salt -in c:\cifrado\fichero.txt -out c:\cifrado\ficherocif.bin
enter des-ede3-cbc encryption password:
Verifying - enter des-ede3-cbc encryption password:OpenSSL>enc -des3 -d -in c:\cifrado\ficherocif.bin -out c:\cifrado\original.txt
enter des-ede3-cbc encryption password:OpenSSL> enc -des-ede3-cbc -d -in c:\cifrado\ficherocif.bin -out c:\cifrado\original.txtenter des-ede3-cbc decryption password:IDEA – International Data Encryption Algorithm
Operates on 64-bit plaintext blocks with a 128-bit key (no parity). It is twice as fast as DES, despite using much longer keys.
OpenSSL> idea-ecb -salt -in c:\csb.log -out c:\csb.idea-ecb.txtenter idea-ecb encryption password:Verifying - enter idea-ecb encryption password:OpenSSL> idea-cbc -salt -in c:\csb.log -out c:\csb.idea-cbc.txtenter idea-cbc encryption password:Verifying - enter idea-cbc encryption password:OpenSSL> idea-ecb -d -in c:\csb.idea-ecb.txt -out c:\csb.idea-ecb.d.txtenter idea-ecb decryption password:OpenSSL> idea-cbc -d -in c:\csb.idea-cbc.txt -out c:\csb.idea-cbc.d.txtenter idea-cbc decryption password:AES
OpenSSL>aes-128-cbc -salt -in c:\cifrado\fichero.txt -out c:\cifrado\fichero.txt.aesDecrypt the previous file to obtain the plaintext message.OpenSSL>aes-128-cbc -d -salt -in c:\cifrado\fichero.txt.aes -out c:\cifrado\fichero.txtThe most secure and fastest:
Encrypt the file “fichero.txt”
OpenSSL>aes-256-cbc -salt -in c:\cifrado\fichero.txt -out c:\cifrado\fichero.txt.aesDecrypt the previous file to obtain the plaintext message.OpenSSL>aes-256-cbc -d -salt -in c:\cifrado\fichero.txt.aes -out c:\cifrado\fichero.txtOpenSSL>cast -in c:\cifrado\fichero.txt -out c:\cifrado\fichrc5.bin
enter cast5-cbc encryption password:
Verifying - enter cast5-cbc encryption password:OpenSSL>cast -d -in fichrc5.bin
enter cast5-cbc decryption password:OpenSSL> cast5-ecb -salt -in c:\csb.log -out c:\csb. cast5-ecb.txtenter cast5-ecb encryption password:Verifying - enter cast5-ecb encryption password:OpenSSL> cast5-ecb -d -in c:\csb.cast5-ecb.txt -out c:\csb.cast5-ecb.d.txtenter cast5-ecb decryption password:OpenSSL> bf -salt -in c:\csb.log -out c:\csb.bf.txtenter bf-cbc encryption password:Verifying - enter bf-cbc encryption password:OpenSSL> bf -d -in c:\csb.bf.txt -out c:\csb.txtenter bf-cbc decryption password:OpenSSL>base64 -in c:\cifrado\ficherocif.bin -out c:\cifrado\base64.txtOpenSSL>base64 -d -in c:\cifrado\base64.txt -out c:\cifrado\ficherocif2.binEncrypt a file using the blowfish algorithm and encode it in base64 in one step.
OpenSSL>enc -e -a -salt -bf -in c:\cifrado\tomcat.jpg -out c:\cifrado\tomcat.blowfish
enter bf-cbc encryption password:
Verifying password - enter bf-cbc encryption password:Decrypt the previous file
OpenSSL>enc -d -a -bf -in c:\cifrado\tomcat.blowfish -out c:\cifrado\tomcat-decrypt.jpg
enter bf-cbc decryption password:OpenSSL> md5 c:\text.txtMD5(c:\text.txt)= 1798c318d32f787b1befd7812c94ff4b