MCRYPT(1)

πŸ’– MCRYPT πŸ’–

okay bestie, listen β€” this is the MCRYPT(1) page, aka the General Commands Manual entry for the crypting trio: crypt, mcrypt, and mdecrypt. grab a strawberry drink πŸ“ and let's get into it.


✨ NAME ✨

crypt, mcrypt, mdecrypt β€” encrypt or decrypt files πŸ”


🌈 SYNOPSIS 🌈

mcrypt [ -dLFubhvrzp ] [-a algorithm] [-c config_file] [-m mode] [-s keysize]
[-o keymode] [-k key1 key2 ...]  [-f keyfile] [ filename ...  ]

mdecrypt [ -LFusbhvzp ] [-a algorithm] [-c config_file] [-m mode]
[-s keysize] [-o keymode] [-k key1 key2 ...]  [-f keyfile] [ filename
...  ]

like… that's a lot of flags and honestly she ate πŸ’… every single one of them is real and you're gonna meet them all below.


πŸ¦‹ DESCRIPTION πŸ¦‹

Mcrypt is a simple crypting program, bestie. it's the glow-up replacement for the old unix crypt(1). when it encrypts or decrypts a file, it makes a new file with the extension .nc and mode 0600. the new file keeps the modification date of the original β€” she's considerate like that πŸŽ€. the original file may be deleted by specifying the -u parameter. and if you don't specify any files at all? the standard input gets encrypted to the standard output. slay.

Mcrypt uses all the symmetric algorithms included in libmcrypt. all of them. the whole roster. πŸ‘‘

crypt is a small shell wrapper around mcrypt to emulate the old unix crypt command. for more information run crypt --help !


🌸 HINTS 🌸

by default, mcrypt, when one of these algorithms is specified, prompts something like:

Enter passphrase: ...

and then you should enter a passphrase long enough (512 characters is the maximum length, no cap). now, in order to encrypt the file, the passphrase is transformed using the specified (or the default) key generation algorithm, plus a random salt. the produced value is then used as the key, which is fed to the algorithm. that's the whole pipeline, gorgeous ✨

Algorithm Vulnerability: most algorithms today are designed to resist in specific attacks. none of them is proved not to be vulnerable to some kind of attack not as yet known. πŸ’€ yeah. that's just the reality.

Compression: by compressing your data before encryption you gain both in efficiency (faster encryption) and safety of your data (language redundancy is removed). a drawback is that most compression programs will add specific headers in the compressed file, thus making known plaintext attacks easier. compression after encryption is useless and may result to compressed files with longer size than the original. so like… order matters, bestie πŸ™ˆ

Error Recovery: there is some error recovery in mcrypt. if bytes are removed or lost from the file or stream in ECB, CBC and OFB modes, are impossible to recover, although CFB mode will recover. if some bytes are altered then a full block of plaintext is affected in ECB mode, two blocks in CBC and CFB modes, but only the corresponding byte in OFB mode. Mcrypt uses a 32 bit CRC to check for errors in the encrypted files. iconic little safety net 🫢

Extra security: for the very paranoid, if mcrypt is executed with superuser privileges it ensures that no important data (keys etc.) are written to disk, as swap etc. keep in mind that mcrypt was not designed to be a setuid program, so you shouldn't make it one.

do not rely on the fact that an algorithm has a large key size β€” try to use long passphrases and try to make them unpredictable. long + chaotic = the vibe. πŸ”₯

all the block algorithms above support these modes of encryption:

  • ECB: the Electronic CodeBook mode. it is the simplest mode to use with a block cipher. encrypts each block independently.
  • CBC: the Cipher Block Chaining mode. it is better than ECB since the plaintext is XOR'ed with the previous ciphertext. a random block is placed as the first block so the same block or messages always encrypt to something different. (this is the default mode) πŸ‘‘
  • CFB: the Cipher-Feedback Mode (in 8bit). this is a self-synchronizing stream cipher implemented from a block cipher.
  • OFB: the Output-Feedback Mode (in 8bit). this is a synchronous stream cipher implemented from a block cipher. it is intended for use in noisy lines, because corrupted ciphertext blocks do not corrupt the plaintext blocks that follow. insecure when used to encrypt large amounts of data, so I recommend against using it. 🚩
  • nOFB: the Output-Feedback Mode (in nbit). n is the size of the block of the algorithm. this is a synchronous stream cipher implemented from a block cipher. it is intended for use in noisy lines, because corrupted ciphertext blocks do not corrupt the plaintext blocks that follow.

encrypted files can be restored to their original form using mcrypt -d or mdecrypt πŸ’œ

mdecrypt takes a list of files on its command line and creates a new file for each file whose name ends with .nc by removing the .nc or by adding .dc to the end of the file name if .nc is not in the encrypted file's name. the way it just… handles the naming for you. main character energy fr fr.


πŸ’… OPTIONS πŸ’…

  • -F, --force β€” force output on standard output or input from stdin if that is a terminal. by default mcrypt will not output encrypted data to terminal, nor read encrypted data from it.
  • -z, --gzip β€” use gzip (if it exists in your system) to compress files before encryption. if specified at decryption time it will decompress these files.
  • -p, --bzip2 β€” use bzip2 (if it exists in your system) to compress files before encryption. if specified at decryption time it will decompress these files.
  • --openpgp-z INT β€” this option will enable compression in OpenPGP (RFC2440) encrypted files.
  • -d, --decrypt β€” decrypt. that's it, that's the whole job 🫑
  • --help β€” display a help screen and quit.
  • -v, --version β€” version. display the version number and quit.
  • -L, --license β€” display the mcrypt's license and quit.
  • -o, --keymode MODE β€” MODE may be one of the keymodes listed by the --list-keymodes parameter. it actually is the conversion to the key before it is fed to the algorithm. it is recommended to leave it as is, if you do not know what it is. however if you still want to use this option, you might want to use the 'hex' mode which allows you to specify the key in hex (and no conversion will by applied).
  • -h, --hash HASH_ALGORITHM β€” HASH_ALGORITHM may be one of the algorithms listed by the --list-hash parameter. this is the digest that will be appended to the file to be encrypted, in order to detect file corruption. the default is the CRC32 checksum.
  • -s, --keysize SIZE β€” SIZE is the algorithm's key size in bytes (not the size of the passphrase). it defaults to the maximum key supported by the algorithm. the maximum key sizes of the algorithms may be obtained by the --list parameter. it is safe not to touch this. hands off, bestie πŸ™ˆ
  • -g, --openpgp β€” this option will make mcrypt to use the OpenPGP (RFC2440) file format for encrypted files. this will make files encrypted by mcrypt accessible from any OpenPGP compliant application.
  • -b, --bare β€” no important information like the algorithm, mode, the bit mode and the crc32 of the original file are written in the encrypted file. the security lies on the algorithm not on obscurity so this is NOT the default. this flag must also be specified when decrypting a bare encrypted file. when the bare flag is specified decryption and encryption are faster. this may be useful when using mcrypt to encrypt a link or something like that.
  • --flush β€” flushes the output (ciphertext or plaintext) immediately. useful if mcrypt is used with pipes.
  • --time β€” prints some timing information (encryption speed etc.)
  • --nodelete β€” when this option is specified mcrypt does not delete the output file, even if decryption failed. this is useful if you want to decrypt a corrupted file.
  • -q, --quiet β€” suppress some not critical warnings. shhh 🀫
  • -u, --unlink β€” unlink (delete) the input file if the whole process of encryption/decryption succeeds. this is not the default in order to use an external program to remove sensitive data.
  • --list β€” lists all the algorithms currently supported.
  • --list-keymodes β€” lists all the key modes currently supported.
  • --list-hash β€” lists all the hash algorithms currently supported.
  • -r, --random β€” use /dev/(s)random instead of /dev/urandom. this may need some key input or mouse move to proceed. if your system does not support /dev/random or /dev/urandom, a random gatherer will be used. wiggle that mouse, queen πŸ–±οΈβœ¨
  • -k, --key KEY1 KEY2 ... β€” enter the keyword(s) via the command line. the KEY(s) is/are then used as keyword instead of prompting for them. keep in mind that someone may see the command you are executing and so your keyword(s). πŸ‘€ dangerous behavior ngl
  • -c, --config FILE β€” use the specified configuration file. the default is .mcryptrc in your home directory. the format of the configuration file is the same as the parameters. an example file is:
 algorithm safer+
 mode cbc
 key a_very_secret_one
  • -f, --keyfile FILE β€” enter the keyword(s) via a file. one keyword is read per line. the first keyword read is used for the first file, the second for the second file etc. if the keywords are less than the files then the last keyword is used for the remaining. a limitation is that you cannot use the NULL (\0) and the Newline (\n) character in the key. a solution to this problem is to specify the keyword in hex mode.
  • -m, --mode MODE β€” mode of encryption and decryption. these modes are currently supported: ECB, CFB, OFB, nOFB, CBC and STREAM. CBC is the default. unless the bare flag is specified there is no need to specify these modes for decryption. for stream algorithms (like WAKE) mode should be STREAM.
  • -a, --algorithm ALGORITHM β€” the algorithm used to encrypt and decrypt. unless the bare flag is specified there is no need to specify these for decryption. the algorithms currently supported are shown with the --list parameter.

πŸŽ€ EXAMPLES πŸŽ€

for mcrypt to be compatible with the solaris des(1), the following parameters are needed:

mcrypt -a des --keymode pkdes --bare --noiv filename

for mcrypt to be compatible with the unix crypt(1), the following parameters are needed:

mcrypt -a enigma --keymode scrypt --bare filename

to encrypt a file using a stream algorithm (eg. Arcfour), the following parameters are needed:

mcrypt -a arcfour --mode stream filename

copy these exactly, bestie. character for character. they're giving "trust the process" 🌟


🧚 ENVIRONMENT 🧚

Mcrypt uses the following environment variables:

  • MCRYPT_KEY: to specify the key
  • MCRYPT_ALGO: to specify the algorithm
  • MCRYPT_MODE: to specify the algorithm's mode
  • MCRYPT_KEY_MODE: to specify the key mode

you can use these instead of using the command line (which is insecure), but note that only one key should be used in MCRYPT_KEY. one key. singular. don't get greedy πŸ™…β™€οΈ


🌈 SEE ALSO 🌈

des_crypt(3)

✨ DIAGNOSTICS ✨

okay so real talk β€” when you run mcrypt and it's living its best life, the exit status is normally 0. That's the "we ate, no crumbs" number. πŸŽ€

But if an error occurs, exit status is something other than 0. That's the "not me, not today" number, and it's your cue that something went sideways. 😭

And here's the usage line, in all its exact glory, so you can clock the whole flag situation at a glance:

Usage: mcrypt [-dLFubhvrzp] [-f keyfile] [-k key1 key2 ...] [-m mode]
       [-o keymode] [-a algorithm] [-c config_file] [filename ...]

πŸ‘‘ AUTHORS πŸ‘‘

This whole thing is Version 2.6.0 Copyright (C) 1998,1999,2000,2001,2002 Nikos Mavroyanopoulos (nmav@gnutls.org). Iconic behavior, honestly. πŸ‘‘

And huge thanks to all the people who reported problems and suggested various improvements for mcrypt; who are too numerous to cite here. Y'all are the real MVPs, fr fr. 🫢


This page is MCRYPT(1), sourced from local, dated 03 May 2003, and carrying Version 2.6.0 energy. Stay encrypted, bestie. πŸ’–βœ¨