OPENSSL-ENC(1ossl)

OpenSSL Β· openssl-enc(1ossl) β€” symmetric cipher routines ✨

πŸŽ€ NAME πŸŽ€

openssl-enc β€” symmetric cipher routines, bestie πŸ’…

✨ SYNOPSIS ✨

openssl enc|cipher [-cipher] [-help] [-list] [-ciphers] [-in filename]
[-out filename] [-pass arg] [-e] [-d] [-a] [-base64] [-A] [-k password]
[-kfile filename] [-K key] [-iv IV] [-S salt] [-salt] [-nosalt] [-z]
[-md digest] [-iter count] [-pbkdf2] [-saltlen size] [-p] [-P] [-bufsize
number] [-nopad] [-v] [-debug] [-none] [-skeymgmt skeymgmt] [-skeyopt
opt:value] [-engine id] [-rand files] [-writerand file] [-provider name]
[-provider-path path] [-provparam [name:]key=value] [-propquery propq]

openssl cipher [...]

πŸ’– DESCRIPTION πŸ’–

Okay so the symmetric cipher commands are literally here to encrypt or decrypt your data 🫢. They work with all kinds of block and stream ciphers, using keys that come from passwords or keys you hand over explicitly. You can also do Base64 encoding or decoding by itself, or stack it on top of the encryption/decryption. It’s giving β€œone command, many vibes” ✨.

πŸ’… OPTIONS πŸ’…

  • -cipher β€” the cipher to use πŸ”₯.
  • -help β€” prints out a usage message, classic.
  • -list β€” lists all supported ciphers πŸ‘‘.
  • -ciphers β€” alias of -list to display all supported ciphers, same energy.
  • -in filename β€” the input filename; standard input by default 🌸.
  • -out filename β€” the output filename; standard output by default πŸŽ€.
  • -pass arg β€” the password source. For more info about the format of arg, see openssl-passphrase-options(1) πŸ”‘.
  • -e β€” encrypt the input data: this is the default πŸ’–.
  • -d β€” decrypt the input data.
  • -a β€” Base64 process the data. That means if encryption is happening, the data is Base64 encoded after encryption. If decryption is set, then the input data is Base64 decoded before being decrypted ✨.

When the -A option is not given, on encoding a newline is inserted after each 64 characters, and on decoding a newline is expected among the first 1024 bytes of input. Important detail, bestie πŸ“.

  • -base64 β€” same as -a.
  • -A β€” if the -a option is set, then Base64 encoding produces output without any newline character, and Base64 decoding does not require any newlines. So it can be helpful to use -A when decoding unknown input πŸ‘€.
  • -k password β€” the password to derive the key from. This is for compatibility with previous versions of OpenSSL. Superseded by the -pass argument 🫢.
  • -kfile filename β€” read the password to derive the key from the first line of filename. This is for compatibility with previous versions of OpenSSL. Superseded by the -pass argument.
  • -md digest β€” use the specified digest to create the key from the passphrase. The default algorithm is sha-256 🧚.
  • -iter count β€” use a given number of iterations on the password in deriving the encryption key. High values increase the time required to brute-force the resulting file. This option enables the use of the PBKDF2 algorithm to derive the key πŸ”₯.
  • -pbkdf2 β€” use PBKDF2 algorithm with a default iteration count of 10000 unless otherwise specified by the -iter command line option.
  • -saltlen size β€” set the salt length to use when using the -pbkdf2 option. For compatibility reasons, the default is 8 bytes. The maximum value is currently 16 bytes. If the -pbkdf2 option is not used, then this option is ignored and a fixed salt length of 8 is used. The salt length used when encrypting must also be used when decrypting ⚠️.
  • -nosalt β€” don’t use a salt in the key derivation routines. This option SHOULD NOT be used except for test purposes or compatibility with ancient versions of OpenSSL πŸ™ˆ.
  • -salt β€” use salt (randomly generated or provided with the -S option) when encrypting; this is the default πŸ§‚βœ¨.
  • -S salt β€” the actual salt to use: this must be represented as a string of hex digits. If this option is used while encrypting, the same exact value will be needed again during decryption. This salt may be truncated or zero padded to match the salt length (see -saltlen) πŸ”.
  • -K key β€” the actual key to use: this must be represented as a string comprised only of hex digits. If only the key is specified, the IV must additionally be specified using the -iv option. When both a key and a password are specified, the key given with the -K option will be used and the IV generated from the password will be taken. It does not make much sense to specify both key and password πŸ’€.
  • -iv IV β€” the actual IV to use: this must be represented as a string comprised only of hex digits. When only the key is specified using the -K option, the IV must explicitly be defined. When a password is being specified using one of the other options, the IV is generated from this password 🌈.
  • -p β€” print out the key and IV used πŸ‘€.
  • -P β€” print out the key and IV used then immediately exit: don’t do any encryption or decryption. Iconic early exit behavior πŸ’….
  • -bufsize number[k] β€” set the buffer size for I/O. The maximum size that can be specified is 2^31-1 (2147483647) bytes. The k suffix can be specified to indicate that number is provided in kibibytes (multiples of 1024 bytes) πŸ“¦.
  • -nopad β€” disable standard block padding 🚫.
  • -v β€” verbose print; display some statistics about I/O and buffer sizes πŸ“Š.
  • -debug β€” debug the BIOs used for I/O πŸ›.
  • -z β€” compress or decompress encrypted data using zlib after encryption or before decryption. This option exists only if OpenSSL was compiled with the zlib or zlib-dynamic option 🌬️.
  • -none β€” use NULL cipher (no encryption or decryption of input) πŸ«₯.
  • -skeymgmt skeymgmt β€” some providers may support opaque symmetric key objects. To use them, we need to know the name of the EVP_SKEYMGMT to be used. If not specified, the name of the cipher will be used πŸ”‘.

To find out the name of the suitable symmetric key management, please refer to the output of the openssl list -skey-managers command πŸ‘‘.

  • -skeyopt opt:value β€” to obtain an existing opaque symmetric key or generate a new one, key options are specified as opt:value. These options can’t be used together with any options implying raw key directly or indirectly ⚠️.
  • -rand files β€” see β€œRandom State Options” in openssl(1) for details 🎲.
  • -writerand file β€” see β€œRandom State Options” in openssl(1) for details.
  • -provider name β€” see β€œProvider Options” in openssl(1), provider(7), and property(7) 🌸.
  • -provider-path path β€” see β€œProvider Options” in openssl(1), provider(7), and property(7).
  • -provparam [name:]key=value β€” see β€œProvider Options” in openssl(1), provider(7), and property(7).
  • -propquery propq β€” see β€œProvider Options” in openssl(1), provider(7), and property(7).
  • -engine id β€” see β€œEngine Options” in openssl(1). This option is deprecated πŸ’€.

πŸ¦‹ NOTES πŸ¦‹

The program can be called either as openssl cipher or openssl enc -cipher. The first form doesn’t work with engine-provided ciphers, because this form is processed before the configuration file is read and any ENGINEs loaded. Use the openssl-list(1) command to get a list of supported ciphers πŸ‘‘.

Engines which provide entirely new encryption algorithms (such as the ccgost engine which provides gost89 algorithm) should be configured in the configuration file. Engines specified on the command line using -engine option can only be used for hardware-assisted implementations of ciphers which are supported by the OpenSSL core or another engine specified in the configuration file πŸ”§.

When the enc command lists supported ciphers, ciphers provided by engines, specified in the configuration files are listed too.

A password will be prompted for to derive the key and IV if necessary πŸ”.

The -salt option should ALWAYS be used if the key is being derived from a password unless you want compatibility with previous versions of OpenSSL ⚠️.

Without the -salt option it is possible to perform efficient dictionary attacks on the password and to attack stream cipher encrypted data. The reason for this is that without the salt the same password always generates the same encryption key. So yeah, salt is not optional vibes, it’s security πŸ’€.

When the salt is generated at random (that means when encrypting using a passphrase without explicit salt given using -S option), the first bytes of the encrypted data are reserved to store the salt for later decrypting 🌈.

Some of the ciphers do not have large keys and others have security implications if not used correctly. A beginner is advised to just use a strong block cipher, such as AES, in CBC mode πŸ‘‘.

All the block ciphers normally use PKCS#7 padding, also known as standard block padding. This allows a rudimentary integrity or password check to be performed. However, since the chance of random data passing the test is better than 1 in 256 it isn’t a very good test 🫠.

If padding is disabled then the input data must be a multiple of the cipher block length.

All RC2 ciphers have the same key and effective key length.

Blowfish and RC5 algorithms use a 128 bit key 🐑.

Please note that OpenSSL 3.0 changed the effect of the -S option. Any explicit salt value specified via this option is no longer prepended to the ciphertext when encrypting, and must again be explicitly provided when decrypting. Conversely, when the -S option is used during decryption, the ciphertext is expected to not have a prepended salt value 🚨.

When using OpenSSL 3.0 or later to decrypt data that was encrypted with an explicit salt under OpenSSL 1.1.1 do not use the -S option, the salt will then be read from the ciphertext. To generate ciphertext that can be decrypted with OpenSSL 1.1.1 do not use the -S option, the salt will then be generated randomly and prepended to the output πŸ’–.

✨ SUPPORTED CIPHERS ✨

okay so real talk bestie: some of these ciphers can be disabled at compile time, and some are only available if the right engine is configured in the configuration file. The output when you invoke this command with the -list option β€” that is, openssl enc -list β€” is a list of ciphers supported by your version of OpenSSL, including ones provided by configured engines. slay πŸ’…

This command does not support authenticated encryption modes like CCM and GCM, and it will not support such modes in the future. Why? Because it has to begin streaming output (e.g., to standard output when -out is not used) before the authentication tag could be validated. When this command is used in a pipeline, the receiving end will not be able to roll back upon authentication failure. The AEAD modes currently in common use also suffer from catastrophic failure of confidentiality and/or integrity upon reuse of key/iv/nonce, and since openssl enc places the entire burden of key/iv/nonce management upon the user, the risk of exposing AEAD modes is too great to allow. the drama is real 😭

These key/iv/nonce management issues also affect other modes currently exposed in this command, but the failure modes are less extreme in these cases, and the functionality cannot be removed with a stable release branch. For bulk encryption of data, whether using authenticated encryption modes or other modes, openssl-cms(1) is recommended, as it provides a standard data format and performs the needed key/iv/nonce management. iconic behavior, honestly ✨

When enc is used with key wrapping modes the input data cannot be streamed, meaning it must be processed in a single pass. Consequently, the input data size must be less than the buffer size (-bufsize arg, default to 8*1024 bytes). The *-wrap ciphers require the input to be a multiple of 8 bytes long, because no padding is involved. The *-wrap-pad ciphers allow any input length. In both cases, no IV is needed. See example below. 🫢

here’s the whole lineup, no skips, no cap:

  • base64 β€” Base 64
  • bf-cbc β€” Blowfish in CBC mode
  • bf β€” alias for bf-cbc
  • blowfish β€” alias for bf-cbc
  • bf-cfb β€” Blowfish in CFB mode
  • bf-ecb β€” Blowfish in ECB mode
  • bf-ofb β€” Blowfish in OFB mode
  • cast-cbc β€” CAST in CBC mode
  • cast β€” alias for cast-cbc
  • cast5-cbc β€” CAST5 in CBC mode
  • cast5-cfb β€” CAST5 in CFB mode
  • cast5-ecb β€” CAST5 in ECB mode
  • cast5-ofb β€” CAST5 in OFB mode
  • chacha20 β€” ChaCha20 algorithm
  • des-cbc β€” DES in CBC mode
  • des β€” alias for des-cbc
  • des-cfb β€” DES in CFB mode
  • des-ofb β€” DES in OFB mode
  • des-ecb β€” DES in ECB mode
  • des-ede-cbc β€” Two key triple DES EDE in CBC mode
  • des-ede β€” Two key triple DES EDE in ECB mode
  • des-ede-cfb β€” Two key triple DES EDE in CFB mode
  • des-ede-ofb β€” Two key triple DES EDE in OFB mode
  • des-ede3-cbc β€” Three key triple DES EDE in CBC mode
  • des-ede3 β€” Three key triple DES EDE in ECB mode
  • des3 β€” alias for des-ede3-cbc
  • des-ede3-cfb β€” Three key triple DES EDE in CFB mode
  • des-ede3-ofb β€” Three key triple DES EDE in OFB mode
  • desx β€” DESX algorithm.
  • gost89 β€” GOST 28147-89 in CFB mode (provided by ccgost engine)
  • gost89-cnt β€” GOST 28147-89 in CNT mode (provided by ccgost engine)
  • idea-cbc β€” IDEA algorithm in CBC mode
  • idea β€” same as idea-cbc
  • idea-cfb β€” IDEA in CFB mode
  • idea-ecb β€” IDEA in ECB mode
  • idea-ofb β€” IDEA in OFB mode
  • rc2-cbc β€” 128 bit RC2 in CBC mode
  • rc2 β€” alias for rc2-cbc
  • rc2-cfb β€” 128 bit RC2 in CFB mode
  • rc2-ecb β€” 128 bit RC2 in ECB mode
  • rc2-ofb β€” 128 bit RC2 in OFB mode
  • rc2-64-cbc β€” 64 bit RC2 in CBC mode
  • rc2-40-cbc β€” 40 bit RC2 in CBC mode
  • rc4 β€” 128 bit RC4
  • rc4-64 β€” 64 bit RC4
  • rc4-40 β€” 40 bit RC4
  • rc5-cbc β€” RC5 cipher in CBC mode
  • rc5 β€” alias for rc5-cbc
  • rc5-cfb β€” RC5 cipher in CFB mode
  • rc5-ecb β€” RC5 cipher in ECB mode
  • rc5-ofb β€” RC5 cipher in OFB mode
  • seed-cbc β€” SEED cipher in CBC mode
  • seed β€” alias for seed-cbc
  • seed-cfb β€” SEED cipher in CFB mode
  • seed-ecb β€” SEED cipher in ECB mode
  • seed-ofb β€” SEED cipher in OFB mode
  • sm4-cbc β€” SM4 cipher in CBC mode
  • sm4 β€” alias for sm4-cbc
  • sm4-cfb β€” SM4 cipher in CFB mode
  • sm4-ctr β€” SM4 cipher in CTR mode
  • sm4-ecb β€” SM4 cipher in ECB mode
  • sm4-ofb β€” SM4 cipher in OFB mode
  • aes-[128|192|256]-cbc β€” 128/192/256 bit AES in CBC mode
  • aes[128|192|256] β€” alias for aes-[128|192|256]-cbc
  • aes-[128|192|256]-cfb β€” 128/192/256 bit AES in 128 bit CFB mode
  • aes-[128|192|256]-cfb1 β€” 128/192/256 bit AES in 1 bit CFB mode
  • aes-[128|192|256]-cfb8 β€” 128/192/256 bit AES in 8 bit CFB mode
  • aes-[128|192|256]-ctr β€” 128/192/256 bit AES in CTR mode
  • aes-[128|192|256]-ecb β€” 128/192/256 bit AES in ECB mode
  • aes-[128|192|256]-ofb β€” 128/192/256 bit AES in OFB mode
  • aes-[128|192|256]-wrap β€” key wrapping using 128/192/256 bit AES
  • aes-[128|192|256]-wrap-pad β€” key wrapping with padding using 128/192/256 bit AES
  • aria-[128|192|256]-cbc β€” 128/192/256 bit ARIA in CBC mode
  • aria[128|192|256] β€” alias for aria-[128|192|256]-cbc
  • aria-[128|192|256]-cfb β€” 128/192/256 bit ARIA in 128 bit CFB mode
  • aria-[128|192|256]-cfb1 β€” 128/192/256 bit ARIA in 1 bit CFB mode
  • aria-[128|192|256]-cfb8 β€” 128/192/256 bit ARIA in 8 bit CFB mode
  • aria-[128|192|256]-ctr β€” 128/192/256 bit ARIA in CTR mode
  • aria-[128|192|256]-ecb β€” 128/192/256 bit ARIA in ECB mode
  • aria-[128|192|256]-ofb β€” 128/192/256 bit ARIA in OFB mode
  • camellia-[128|192|256]-cbc β€” 128/192/256 bit Camellia in CBC mode
  • camellia[128|192|256] β€” alias for camellia-[128|192|256]-cbc
  • camellia-[128|192|256]-cfb β€” 128/192/256 bit Camellia in 128 bit CFB mode
  • camellia-[128|192|256]-cfb1 β€” 128/192/256 bit Camellia in 1 bit CFB mode
  • camellia-[128|192|256]-cfb8 β€” 128/192/256 bit Camellia in 8 bit CFB mode
  • camellia-[128|192|256]-ctr β€” 128/192/256 bit Camellia in CTR mode
  • camellia-[128|192|256]-ecb β€” 128/192/256 bit Camellia in ECB mode
  • camellia-[128|192|256]-ofb β€” 128/192/256 bit Camellia in OFB mode

πŸ’– EXAMPLES πŸ’–

Just base64 encode a binary file, bestie:

openssl base64 -in file.bin -out file.b64

Decode the same file:

openssl base64 -d -in file.b64 -out file.bin

Encrypt a file using AES-128 using a prompted password and PBKDF2 key derivation:

openssl enc -aes128 -pbkdf2 -in file.txt -out file.aes128

Decrypt a file using a supplied password:

openssl enc -aes128 -pbkdf2 -d -in file.aes128 -out file.txt \
   -pass pass:<password>

Encrypt a file then base64 encode it (so it can be sent via mail for example) using AES-256 in CTR mode and PBKDF2 key derivation:

openssl enc -aes-256-ctr -pbkdf2 -a -in file.txt -out file.aes256

Base64 decode a file then decrypt it using a password supplied in a file:

openssl enc -aes-256-ctr -pbkdf2 -d -a -in file.aes256 -out file.txt \
   -pass file:<passfile>

AES key wrapping:

openssl enc -e -a -id-aes128-wrap-pad -K 000102030405060708090A0B0C0D0E0F -in file.bin

or

openssl aes128-wrap-pad -e -a -K 000102030405060708090A0B0C0D0E0F -in file.bin

😭 BUGS 😭

The -A option when used with large files doesn’t work properly. not me finding out the hard way πŸ’€

On the other hand, when base64 decoding without the -A option, if the first 1024 bytes of input do not include a newline character the first two lines of input are ignored. iykyk πŸ™ˆ

The openssl enc command only supports a fixed number of algorithms with certain parameters. So if, for example, you want to use RC2 with a 76 bit key or RC4 with an 84 bit key you can’t use this program.


πŸ‘€ SEE ALSO πŸ‘€

openssl-list(1), EVP_SKEY(3)


πŸ•°οΈ HISTORY πŸ•°οΈ

  • The default digest was changed from MD5 to SHA256 in OpenSSL 1.1.0.
  • The -list option was added in OpenSSL 1.1.1e.
  • The -ciphers and -engine options were deprecated in OpenSSL 3.0.
  • The -saltlen option was added in OpenSSL 3.2.
  • The -skeymgmt and -skeyopt options were added in OpenSSL 3.5.

Copyright 2000-2025 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


and that’s the whole vibe bestie πŸ’– β€” this page is from version 3.5.9, dated 2026-09-29, and it’s OPENSSL-ENC(1ossl), periodt βœ¨πŸ‘‘

πŸ“¦ where this page comes from