User Tools

Site Tools


howtos:file_encryption_with_openssl

Encrypt file:

$ openssl aes-256-cbc -salt -in file-test -out file-test.aes
enter aes-256-cbc encryption password:
Verifying - enter aes-256-cbc encryption password:

Decrypt file:

$ openssl aes-256-cbc -d -in file-test.aes -out file-test-dec

Encrypt file and convert it to Base64:

$ openssl aes-256-cbc -a -salt -in file-test -out file-test-64

And this way to decrypt it:

$ openssl aes-256-cbc -d -a -in file-test-64 -out file-64.dec

Append password onto the encrypt command:

$ openssl aes-256-cbc -a -salt -in file-test -out file-test-64 -k password

Encrypt one-liner with password from a file:

$ for f in * ; do [ -f $f ] && openssl aes-256-cbc -salt -in $f -out $f.enc -pass file:password.txt ; done

Encrypt one-liner with password in commandline:

$ password="password123";for f in * ; do [ -f $f ] && openssl aes-256-cbc -salt -in $f -out $f.enc -k $password ; done

Hashes:

$ openssl sha1 file-test-64
SHA1(eapol-64)= afc594f26ca0878073769d24f8c04fe35f2bf8b3

Hash of files in current directory:

$ ls * | xargs openssl sha1

Replace “sha1” with “md5” if you need the md5 hash instead.


Source: http://olex.openlogic.com/wazi/2011/more-slick-openssl-tricks/

howtos/file_encryption_with_openssl.txt · Last modified: 02/12/2018 21:34 by 127.0.0.1