openssl enc

The openssl subcommand that encrypts or decrypts files and data streams with a symmetric cipher such as AES.

In more detail

You choose the cipher and mode by name, such as -aes-256-ctr, and supply either a raw key and IV with -K and -iv or a password with -pass, where -pbkdf2 turns the password into a key; -d decrypts. It does not support authenticated modes such as GCM, so its output can be altered without detection, and real systems are better served by a library with AEAD.

Examples

cmd = ["openssl", "enc", "-aes-256-ctr", "-K", KEY, "-iv", IV]
openssl enc -aes-256-cbc -pbkdf2 -pass file:db.key -in customers.db -out customers.db.enc
openssl enc -d -aes-256-cbc -pbkdf2 -pass file:db.key -in customers.db.enc -out restored.db

Related terms

Taught in

References

Certification courses