OpenSSL Encryption and Decryption Techniques

Classified in Computers

Written on in English with a size of 109.42 KB

OpenSSL Encryption and Decryption Commands

RC4 Symmetric Encryption

To encrypt the file "fichero.txt" using the RC4 symmetric encryption algorithm:

OpenSSL> rc4 -in c:\cifrado\fichero.txt -out c:\cifrado\cifrado.rc4
enter rc4 encryption password:
Verifying - enter rc4 encryption password:

To decrypt the previously encrypted file:

OpenSSL> rc4 -d -in c:\cifrado\cifrado.rc4 -out c:\cifrado\descifrado.txt
enter rc4 decryption password:

DES Encryption

Encrypting a file:

OpenSSL> des -salt -in c:\csb.log -out c:\csb.bf.txt
enter des-cbc encryption password:
Verifying - enter des-cbc encryption password:

Decrypting a file:

OpenSSL> des -d -in c:\csb.bf.txt -out c:\csb.txt
enter des-cbc decryption password:

Triple DES (DES3) Algorithm

Encrypting a file:

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:

Decrypting a file:

OpenSSL>enc -des3 -d -in c:\cifrado\ficherocif.bin -out c:\cifrado\original.txt
enter des-ede3-cbc decryption password:

IDEA - International Data Encryption Algorithm

IDEA operates on 64-bit plaintext with a 128-bit key (no parity). It is twice as fast as DES, despite using much longer keys.

Encrypting using IDEA ECB:

OpenSSL> idea-ecb -salt -in c:\csb.log -out c:\csb.idea-ecb.txt
enter idea-ecb encryption password:
Verifying - enter idea-ecb encryption password:

Encrypting using IDEA CBC:

OpenSSL> idea-cbc -salt -in c:\csb.log -out c:\csb.idea-cbc.txt
enter idea-cbc encryption password:
Verifying - enter idea-cbc encryption password:

Decrypting using IDEA ECB:

OpenSSL> idea-ecb -d -in c:\csb.idea-ecb.txt -out c:\csb.idea-ecb.d.txt
enter idea-ecb decryption password:

Decrypting using IDEA CBC:

OpenSSL> idea-cbc -d -in c:\csb.idea-cbc.txt -out c:\csb.idea-cbc.d.txt
enter idea-cbc decryption password:

AES Encryption

Using AES-128-CBC:

OpenSSL>aes-128-cbc -salt -in c:\cifrado\fichero.txt -out c:\cifrado\fichero.txt.aes
Descifrar el fichero anterior para obtener el mensaje en claro.
OpenSSL>aes-128-cbc -d -salt -in c:\cifrado\fichero.txt.aes -out c:\cifrado\fichero.txt

The most secure and fastest:

Encrypting the file "fichero.txt" using AES-256-CBC:

OpenSSL>aes-256-cbc -salt -in c:\cifrado\fichero.txt -out c:\cifrado\fichero.txt.aes
Descifrar el fichero anterior para obtener el mensaje en claro.
OpenSSL>aes-256-cbc -d -salt -in c:\cifrado\fichero.txt.aes -out c:\cifrado\fichero.txt

CAST5 Encryption

Encrypting using CAST5 CBC:

OpenSSL>cast -in c:\cifrado\fichero.txt -out c:\cifrado\fichrc5.bin
enter cast5-cbc encryption password:
Verifying - enter cast5-cbc encryption password:

Decrypting using CAST5 CBC:

OpenSSL>cast -d -in fichrc5.bin
enter cast5-cbc decryption password:

Encrypting using CAST5 ECB:

OpenSSL> cast5-ecb -salt -in c:\csb.log -out c:\csb. cast5-ecb.txt
enter cast5-ecb encryption password:
Verifying - enter cast5-ecb encryption password:

Decrypting using CAST5 ECB:

OpenSSL> cast5-ecb -d -in c:\csb.cast5-ecb.txt -out c:\csb.cast5-ecb.d.txt
enter cast5-ecb decryption password:

Blowfish (BF) Encryption

Encrypting using Blowfish CBC:

OpenSSL> bf -salt -in c:\csb.log -out c:\csb.bf.txt
enter bf-cbc encryption password:
Verifying - enter bf-cbc encryption password:

Decrypting using Blowfish CBC:

OpenSSL> bf -d -in c:\csb.bf.txt -out c:\csb.txt
enter bf-cbc decryption password:

Base64 Encoding and Decoding

Encoding a file to Base64:

OpenSSL>base64 -in c:\cifrado\ficherocif.bin -out c:\cifrado\base64.txt

Decoding a Base64 file:

OpenSSL>base64 -d -in c:\cifrado\base64.txt -out c:\cifrado\ficherocif2.bin

Combined Blowfish Encryption and Base64 Encoding

Encrypt a file using the Blowfish algorithm and encode it in Base64 in a single 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:

MD5 Hashing

Calculating the MD5 hash of a file:

OpenSSL> md5 c:\text.txt
MD5(c:\text.txt)= 1798c318d32f787b1befd7812c94ff4b

Imagen

Related entries: