OPENSSL-ENC(1SSL)

✨ NAME ✨

okay bestie, welcome to openssl-enc πŸ’– β€” that's her name in the docs, and this whole page lives in the OpenSSL manual, section 1SSL. so like, fancy. she does symmetric cipher routines and she eats, no cap. πŸ‘‘


πŸ¦‹ 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] [-skeyuri uri] [-storepass arg] [-rand files] [-writerand
file] [-provider name] [-provider-path path] [-provparam
[name:]key=value] [-propquery propq]

openssl cipher [...]

🌸 DESCRIPTION 🌸

so the symmetric cipher commands are the ones that let you encrypt or decrypt your data with a whole roster of block and stream ciphers, and the keys can either come from passwords or just like, be handed over explicitly. πŸ’…

and base64 encoding or decoding? yeah she does that too β€” either all by its lonesome, or stacked right on top of the encryption/decryption. versatile queen. πŸŽ€


πŸ’… OPTIONS πŸ’…

  • -cipher β€” the cipher you wanna use. and listen, this one is quirky: you prepend a hyphen to the cipher name (like -aes-256-cbc), you do NOT pass it as an argument to some -cipher flag. run openssl list -cipher-algorithms to see what's available. πŸ¦‹
  • -help β€” prints out a usage message. the humble fave.
  • -list β€” lists every supported cipher.
  • -ciphers β€” alias of -list, also shows all supported ciphers. same energy, different name. πŸ’–
  • -in filename β€” the input filename. defaults to standard input.
  • -out filename β€” the output filename. defaults to standard output.
  • -pass arg β€” the password source. for the tea on what format arg takes, go see openssl-passphrase-options(1).
  • -e β€” encrypt the input data. this is the default, she's already doing it. ✨
  • -d β€” decrypt the input data.
  • -a β€” base64 process the data. so: if encryption is happening, the data gets base64 encoded after encryption. if decryption is set, the input data gets 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.

  • -base64 β€” same as -a. literally the same. πŸ’…
  • -A β€” if -a is set, then base64 encoding produces output without any newline character at all, and base64 decoding doesn't require any newlines either. so it can be helpful to use -A when you're decoding unknown input. πŸ‘€
  • -k password β€” the password to derive the key from. this exists for compatibility with previous versions of OpenSSL. superseded by the -pass argument (she moved on, respectfully).
  • -kfile filename β€” read the password to derive the key from, taking it from the first line of filename. also for compatibility with previous versions of OpenSSL. also superseded by -pass.
  • -md digest β€” use the specified digest to create the key from the passphrase. default algorithm is sha-256. 🌸
  • -iter count β€” use a given number of iterations on the password while deriving the encryption key. high values increase the time required to brute-force the resulting file (good!! harder to crack!!). this option enables the use of 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 β€” 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 -pbkdf2 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 β€” remember that, bestie. 🫢
  • -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. like, ancient ancient. πŸ’€
  • -salt β€” use salt (randomly generated, or provided with the -S option) when encrypting. this is the default.
  • -S salt β€” the actual salt to use: it must be represented as a string of hex digits. if you use this while encrypting, the exact same 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: it must be represented as a string made up 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 -K will be used and the IV generated from the password will be taken. honestly it doesn't make much sense to specify both key and password. πŸ™ˆ
  • -iv IV β€” the actual IV to use: also a string made up only of hex digits. when only the key is specified using -K, 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. nosy but helpful. πŸ‘‘
  • -P β€” print out the key and IV used, then immediately exit: don't do any encryption or decryption. she peeks and dips.
  • -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; displays some statistics about I/O and buffer sizes. she's chatty, we love her.
  • -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). it's giving "nothing but make it official". πŸ“
  • -skeymgmt skeymgmt β€” some providers may support opaque symmetric keys 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. ⚠️
  • -skeyuri uri β€” the URI identifying the symmetric key object to be used for encryption. this option can't be used together with any options implying raw key directly or indirectly. the -skeymgmt option is ignored. if both -skeyuri and -skeyopt options are provided, -skeyuri is ignored. messy but that's the rule πŸ’…
  • -storepass arg β€” the input URI password source. for more info about the format of arg, see openssl-passphrase-options(1).
  • -rand files, -writerand file β€” see "Random State Options" in openssl(1) for details. 🌈
  • -provider name, -provider-path path, -provparam [name:]key=value, -propquery propq β€” see "Provider Options" in openssl(1), provider(7), and property(7).

πŸ‘‘ NOTES πŸ‘‘

okay so now the important lore, bestie, listen up:

  • the program can be called either as openssl cipher or openssl enc -cipher. use the openssl-list(1) command to get a list of supported ciphers.
  • when the enc command lists supported ciphers, ciphers provided by providers (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. like, always always.
  • without the -salt option it is possible to perform efficient dictionary attacks on the password and to attack stream cipher encrypted data. the reason? without the salt, the same password always generates the same encryption key. 😭 so yeah, that's bad, that's the whole problem.
  • when the salt is generated at random (that means when encrypting using a passphrase without an explicit salt given using the -S option), the first bytes of the encrypted data are reserved to store the salt for later decrypting. cute little bookmark for future you. πŸŽ€
  • some of the ciphers don't 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. (do this. trust. 🫢)
  • 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. and 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 first things first bestie β€” some of these ciphers can be disabled at compile time, and some only show up if the right provider is configured in the configuration file. so like, what you see depends on your setup πŸ’…

the output you get when you run this command with the -list option (yes, that's openssl enc -list) is a list of ciphers supported by your version of OpenSSL, including the ones provided by whatever providers you've configured. it's giving "your mileage may vary" energy fr fr 🌸


⚠️ BIG WARNING TIME ⚠️ this command does not support authenticated encryption modes like CCM and GCM, and it will not support such modes in the future. not ever. periodt.

why tho?? because it'd have to begin streaming output (like, to standard output when -out isn't used) before the authentication tag could be validated. so when this command is used in a pipeline, the receiving end won't be able to roll back if authentication fails 😭

and ngl it gets worse β€” 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 you, the risk of exposing AEAD modes is too great to allow. these key/iv/nonce management issues also affect other modes currently exposed in this command, but the failure modes are less extreme in those cases, and the functionality can't be removed with a stable release branch. so yeah. for bulk encryption of data, whether using authenticated encryption modes or other modes, openssl-cms(1) is recommended, because it provides a standard data format and does the needed key/iv/nonce management 🫢


okay now for key wrapping modes πŸ“¦ β€” when enc is used with these, 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 the example below πŸ‘‡


The Cipher Menu πŸ“

  • 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 CFB mode
  • des-ede3-ofb β€” Three key triple DES EDE in OFB mode
  • desx β€” DESX algorithm.
  • 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 πŸ¦‹

kay so just base64 encode a binary file, cute and simple:

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

decode the same file, reverse it bestie:

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 πŸ’€ (yes we're airing the flaws, no cap)

  • the -A option when used with large files doesn't work properly πŸ™ˆ
  • 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 😭

also: 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. sorry bestie, it's just not that girl 🫠


🌈 SEE ALSO 🌈


πŸ‘‘ 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 option was 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
  • the -engine option was removed in OpenSSL 4.0
  • the -skeyuri and -storepass options were added in OpenSSL 4.0

Copyright 2000-2026 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>.


aaaand that's a wrap on the whole page bestie πŸŽ€ this one came from OpenSSL version 4.0.3, dated 2026-09-29, and it lives under the name OPENSSL-ENC(1SSL). go forth and encrypt responsibly, mwah πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from