Linux – OpenSSL and what encryption method to use

encryptionlinuxmacosopensslSecurity

I am on OS X 10.8.3, savvy with a command-line and I want to use OpenSSL to start encrypting sensitive information on my MacBook Pro

I know that I can use openSSL in a syntax like:

openssl enc -aes-256-ecb -in in.txt -out encrypted.txt

Can anyone explain what encryption type to use and why?

Also, Can I paste in a string to that openSSL command and get back an encrypted string to store in a file? (say a password list). Store each password encrypted in the text file and then encrypt the entire file as well.

I also assume that one can encrypt one way, then encrypt a second time using a different method for added protection.

if I encrypt this on OS X I also assume that I could decrypt it on Linux.

Best Answer

You need to pay attention to this points while crypting anything:

● Confidentiality
● Integrity
● Authenticity
● Non-repudiation
● Access control
● Difficulty compromise

Taking this as the base you shoud choose the method wich helps you the most. (Being an Asymetric cypher a great way of accommplish a lot of the above.[Use a private and a public key..])

Also Here's the GPG QuickStart Guide.

In the symetric ways there is AES(128, 192, 256 bits) and DES(64 bit per block)

Check this part of this OpenSSL Manual

As someone says above using GPG is a great Idea beacuse of the use of Assymetric Keys which is always safer than just Passwords in any access...

To get a list of Cipher methos you can use:

openssl list-cipher-commands

So for example an AES Cipher:

openssl enc -aes-256-cbc -salt -in file.txt -out file.enc

And to decrypt

openssl enc -d -aes-256-cbc -a -in file.enc

Still, you may have occasion to want to encrypt a file without having to build or use a key/certificate structure.

In the link there is the How do I base64-encode something? part and the How do I simply encrypt a file? part. Hope this can help you

For more info Dive onto Asymmetric key techniques and Symmetric-key

Here's the RFC for Determining Strengths For Public Keys Used For Exchanging Symmetric Keys

Hope this helps. Remember Always to read the manual of what you use.

Related Question