Constante predefinite
Constantele de mai jos sunt definite de această extensie și vor fi disponibile
doar dacă această extensie a fost compilată în interiorul PHP, sau a fost
încărcată dinamic în timpul rulării.
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 a block cipher mode that is generally
unsuitable for most purposes. The use of this mode is not recommended.
-
MCRYPT_MODE_CBC
(cipher block
chaining
) is a block cipher mode that is significantly
more secure than ECB
mode.
-
MCRYPT_MODE_CFB
(cipher
feedback, in 8-bit mode
) is a stream cipher mode.
It is recommended to use NCFB
mode rather
than CFB
mode.
-
MCRYPT_MODE_OFB
(output feedback, in
8-bit mode
) is a stream cipher mode comparable to CFB
, but
can be used in applications where error propagation cannot
be tolerated.
It is recommended to use NOFB
mode rather
than OFB
mode.
-
MCRYPT_MODE_NOFB
(output feedback,
in n-bit mode
) is comparable to OFB
mode,
but operates on the full block size of the algorithm.
-
MCRYPT_MODE_STREAM
is an extra mode to include
some stream algorithms like "WAKE"
or "RC4"
.
Mcrypt supports some other modes of operation for which there are no predefined constants.
They can be utilised by passing a string in place of the missing constants.
-
"ctr"
(counter mode
) is a stream cipher mode.
-
"ncfb"
(cipher feedback,
in n-bit mode
) is comparable to CFB
mode,
but operates on the full block size of the algorithm.
Some other mode and random device constants:
-
MCRYPT_ENCRYPT
(int)
-
-
MCRYPT_DECRYPT
(int)
-
-
MCRYPT_DEV_RANDOM
(int)
-
-
MCRYPT_DEV_URANDOM
(int)
-
-
MCRYPT_RAND
(int)
-
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
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