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-cipherflag. runopenssl list -cipher-algorithmsto 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 formatargtakes, go seeopenssl-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-ais 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-Awhen 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-passargument (she moved on, respectfully).-kfile filenameβ read the password to derive the key from, taking it from the first line offilename. 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 issha-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 of10000unless otherwise specified by the-itercommand line option. π₯-saltlenβ set the salt length to use when using the-pbkdf2option. for compatibility reasons, the default is8bytes. the maximum value is currently16bytes. if-pbkdf2is 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 β 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-Soption) 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-ivoption. when both a key and a password are specified, the key given with-Kwill 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 is2^31-1(2147483647) bytes. theksuffix can be specified to indicate thatnumberis 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 thezliborzlib-dynamicoption.-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 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.
-skeyopt opt: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. β οΈ-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-skeymgmtoption is ignored. if both-skeyuriand-skeyoptoptions are provided,-skeyuriis ignored. messy but that's the rule π-storepass argβ the input URI password source. for more info about the format ofarg, seeopenssl-passphrase-options(1).-rand files,-writerand fileβ see "Random State Options" inopenssl(1)for details. π-provider name,-provider-path path,-provparam [name:]key=value,-propquery propqβ see "Provider Options" inopenssl(1),provider(7), andproperty(7).
π NOTES π
okay so now the important lore, bestie, listen up:
- the program can be called either as
openssl cipheroropenssl enc -cipher. use theopenssl-list(1)command to get a list of supported ciphers. - when the
enccommand 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
-saltoption 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
-saltoption 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
-Soption), 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
-Soption. 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-Soption 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
-Soption β 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-Soption β 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 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 CFB modedes-ede3-ofbβ Three key triple DES EDE in OFB modedesxβ DESX algorithm.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 π¦
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
-Aoption when used with large files doesn't work properly π - on the other hand, when base64 decoding without the
-Aoption, 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
-listoption was added in OpenSSL 1.1.1e - the
-ciphersoption was deprecated in OpenSSL 3.0 - the
-saltlenoption was added in OpenSSL 3.2 - the
-skeymgmtand-skeyoptoptions were added in OpenSSL 3.5 - the
-engineoption was removed in OpenSSL 4.0 - the
-skeyuriand-storepassoptions were added in OpenSSL 4.0
π COPYRIGHT π
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
- ubuntu stonking: openssl 4.0.3-1ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms