예약 상수

이 확장은 다음의 상수들을 정의합니다. 이 확장을 PHP에 내장했거나, 실행시에 동적으로 읽어들일 경우에만 사용할 수 있습니다.

Mcrypt can operate in four block cipher modes (CBC, OFB, CFB, and ECB). If linked against libmcrypt-2.4.x or higher the functions can also operate in the block cipher mode nOFB and in STREAM mode. Below you find a list with all supported encryption modes together with the constants that are defined for the encryption mode. For a more complete reference and discussion see Applied Cryptography by Schneier (ISBN 0-471-11709-9).

  • MCRYPT_MODE_ECB (electronic codebook) is suitable for random data, such as encrypting other keys. Since data there is short and random, the disadvantages of ECB have a favorable negative effect.
  • MCRYPT_MODE_CBC (cipher block chaining) is especially suitable for encrypting files where the security is increased over ECB significantly.
  • MCRYPT_MODE_CFB (cipher feedback) is the best mode for encrypting byte streams where single bytes must be encrypted.
  • MCRYPT_MODE_OFB (output feedback, in 8bit) is comparable to CFB, but can be used in applications where error propagation cannot be tolerated. It's insecure (because it operates in 8bit mode) so it is not recommended to use it.
  • MCRYPT_MODE_NOFB (output feedback, in nbit) is comparable to OFB, but more secure because it operates on the block size of the algorithm.
  • MCRYPT_MODE_STREAM is an extra mode to include some stream algorithms like "WAKE" or "RC4".

Some other mode and random device constants:

MCRYPT_ENCRYPT (integer)
MCRYPT_DECRYPT (integer)
MCRYPT_DEV_RANDOM (integer)
MCRYPT_DEV_URANDOM (integer)
MCRYPT_RAND (integer)

add a note add a note

User Contributed Notes 2 notes

up
7
gordon at vixo dot com
11 years ago
These constants don't cover all the possible options.

There are two constants:
MCRYPT_MODE_OFB
MCRYPT_MODE_NOFB

These relate to using OFB mode in 8-bit feedback mode and using the same feedback length as the key

There is one constant
MCRYPT_MODE_CFB which uses 8-bit feedback mode

There ought to be a constant
MCRYPT_MODE_NCFB which uses the same feedback length as the key.

In fact you can just use the option 'ncfb' in mycrypt
up
-16
Andrey Andreev
10 years ago
You can just use strings instead of the constants ... they are useless and lacking for other modes that are fully supported. Here's a list:

cbc
ecb
ofb
nofb
cfb
ncfb
ctr
stream
To Top