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-listto display all supported ciphers, same energy.-infilename β the input filename; standard input by default πΈ.-outfilename β the output filename; standard output by default π.-passarg β the password source. For more info about the format of arg, seeopenssl-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-aoption 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-Awhen decoding unknown input π.-kpassword β the password to derive the key from. This is for compatibility with previous versions of OpenSSL. Superseded by the-passargument π«Ά.-kfilefilename β 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-passargument.-mddigest β use the specified digest to create the key from the passphrase. The default algorithm issha-256π§.-itercount β 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 of10000unless otherwise specified by the-itercommand line option.-saltlensize β set the salt length to use when using the-pbkdf2option. For compatibility reasons, the default is8bytes. The maximum value is currently16bytes. If the-pbkdf2option is not used, then this option is ignored and a fixed salt length of8is 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-Soption) when encrypting; this is the default π§β¨.-Ssalt β 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) π.-Kkey β 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-ivoption. When both a key and a password are specified, the key given with the-Koption 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 π.-ivIV β 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-Koption, 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 π .-bufsizenumber[k] β set the buffer size for I/O. The maximum size that can be specified is2^31-1(2147483647) bytes. Theksuffix can be specified to indicate that number is provided in kibibytes (multiples of1024bytes) π¦.-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 thezliborzlib-dynamicoption π¬οΈ.-noneβ use NULL cipher (no encryption or decryption of input) π«₯.-skeymgmtskeymgmt β some providers may support opaque symmetric key objects. To use them, we need to know the name of theEVP_SKEYMGMTto 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 π.
-skeyoptopt:value β to obtain an existing opaque symmetric key or generate a new one, key options are specified asopt:value. These options canβt be used together with any options implying raw key directly or indirectly β οΈ.-randfiles β see βRandom State Optionsβ inopenssl(1)for details π².-writerandfile β see βRandom State Optionsβ inopenssl(1)for details.-providername β see βProvider Optionsβ inopenssl(1),provider(7), andproperty(7)πΈ.-provider-pathpath β see βProvider Optionsβ inopenssl(1),provider(7), andproperty(7).-provparam[name:]key=value β see βProvider Optionsβ inopenssl(1),provider(7), andproperty(7).-propquerypropq β see βProvider Optionsβ inopenssl(1),provider(7), andproperty(7).-engineid β see βEngine Optionsβ inopenssl(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 64bf-cbcβ Blowfish in CBC modebfβ alias forbf-cbcblowfishβ alias forbf-cbcbf-cfbβ Blowfish in CFB modebf-ecbβ Blowfish in ECB modebf-ofbβ Blowfish in OFB modecast-cbcβ CAST in CBC modecastβ alias forcast-cbccast5-cbcβ CAST5 in CBC modecast5-cfbβ CAST5 in CFB modecast5-ecbβ CAST5 in ECB modecast5-ofbβ CAST5 in OFB modechacha20β ChaCha20 algorithmdes-cbcβ DES in CBC modedesβ alias fordes-cbcdes-cfbβ DES in CFB modedes-ofbβ DES in OFB modedes-ecbβ DES in ECB modedes-ede-cbcβ Two key triple DES EDE in CBC modedes-edeβ Two key triple DES EDE in ECB modedes-ede-cfbβ Two key triple DES EDE in CFB modedes-ede-ofbβ Two key triple DES EDE in OFB modedes-ede3-cbcβ Three key triple DES EDE in CBC modedes-ede3β Three key triple DES EDE in ECB modedes3β alias fordes-ede3-cbcdes-ede3-cfbβ Three key triple DES EDE in CFB modedes-ede3-ofbβ Three key triple DES EDE in OFB modedesxβ 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 modeideaβ same asidea-cbcidea-cfbβ IDEA in CFB modeidea-ecbβ IDEA in ECB modeidea-ofbβ IDEA in OFB moderc2-cbcβ 128 bit RC2 in CBC moderc2β alias forrc2-cbcrc2-cfbβ 128 bit RC2 in CFB moderc2-ecbβ 128 bit RC2 in ECB moderc2-ofbβ 128 bit RC2 in OFB moderc2-64-cbcβ 64 bit RC2 in CBC moderc2-40-cbcβ 40 bit RC2 in CBC moderc4β 128 bit RC4rc4-64β 64 bit RC4rc4-40β 40 bit RC4rc5-cbcβ RC5 cipher in CBC moderc5β alias forrc5-cbcrc5-cfbβ RC5 cipher in CFB moderc5-ecbβ RC5 cipher in ECB moderc5-ofbβ RC5 cipher in OFB modeseed-cbcβ SEED cipher in CBC modeseedβ alias forseed-cbcseed-cfbβ SEED cipher in CFB modeseed-ecbβ SEED cipher in ECB modeseed-ofbβ SEED cipher in OFB modesm4-cbcβ SM4 cipher in CBC modesm4β alias forsm4-cbcsm4-cfbβ SM4 cipher in CFB modesm4-ctrβ SM4 cipher in CTR modesm4-ecbβ SM4 cipher in ECB modesm4-ofbβ SM4 cipher in OFB modeaes-[128|192|256]-cbcβ 128/192/256 bit AES in CBC modeaes[128|192|256]β alias foraes-[128|192|256]-cbcaes-[128|192|256]-cfbβ 128/192/256 bit AES in 128 bit CFB modeaes-[128|192|256]-cfb1β 128/192/256 bit AES in 1 bit CFB modeaes-[128|192|256]-cfb8β 128/192/256 bit AES in 8 bit CFB modeaes-[128|192|256]-ctrβ 128/192/256 bit AES in CTR modeaes-[128|192|256]-ecbβ 128/192/256 bit AES in ECB modeaes-[128|192|256]-ofbβ 128/192/256 bit AES in OFB modeaes-[128|192|256]-wrapβ key wrapping using 128/192/256 bit AESaes-[128|192|256]-wrap-padβ key wrapping with padding using 128/192/256 bit AESaria-[128|192|256]-cbcβ 128/192/256 bit ARIA in CBC modearia[128|192|256]β alias foraria-[128|192|256]-cbcaria-[128|192|256]-cfbβ 128/192/256 bit ARIA in 128 bit CFB modearia-[128|192|256]-cfb1β 128/192/256 bit ARIA in 1 bit CFB modearia-[128|192|256]-cfb8β 128/192/256 bit ARIA in 8 bit CFB modearia-[128|192|256]-ctrβ 128/192/256 bit ARIA in CTR modearia-[128|192|256]-ecbβ 128/192/256 bit ARIA in ECB modearia-[128|192|256]-ofbβ 128/192/256 bit ARIA in OFB modecamellia-[128|192|256]-cbcβ 128/192/256 bit Camellia in CBC modecamellia[128|192|256]β alias forcamellia-[128|192|256]-cbccamellia-[128|192|256]-cfbβ 128/192/256 bit Camellia in 128 bit CFB modecamellia-[128|192|256]-cfb1β 128/192/256 bit Camellia in 1 bit CFB modecamellia-[128|192|256]-cfb8β 128/192/256 bit Camellia in 8 bit CFB modecamellia-[128|192|256]-ctrβ 128/192/256 bit Camellia in CTR modecamellia-[128|192|256]-ecbβ 128/192/256 bit Camellia in ECB modecamellia-[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 π
π°οΈ HISTORY π°οΈ
- The default digest was changed from MD5 to SHA256 in OpenSSL 1.1.0.
- The
-listoption was added in OpenSSL 1.1.1e. - The
-ciphersand-engineoptions were deprecated in OpenSSL 3.0. - The
-saltlenoption was added in OpenSSL 3.2. - The
-skeymgmtand-skeyoptoptions were added in OpenSSL 3.5.
Β©οΈ COPYRIGHT Β©οΈ
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
- alpine 3.23: openssl-doc 3.5.9-r0 Β· Apache-2.0
- alpine 3.24: openssl-doc 3.5.9-r0 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms