mcrypt cipher mode question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
itbegary
Forum Commoner
Posts: 34
Joined: Sun Jan 05, 2003 2:50 am

mcrypt cipher mode question

Post by itbegary »

The PHP documentation states that mcrypt can operate in four block cipher modes (CBC, OFB, CFB, and ECB). When I first created my encryption code the sample used OFB but I noticed that many people are not posting code using ECB.

What are the major differences between all four of these, if any? Is there a complelling reason to switch from one to another?

Thanks...
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

PHP.net wrote: #

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.
itbegary
Forum Commoner
Posts: 34
Joined: Sun Jan 05, 2003 2:50 am

Post by itbegary »

I think that CBC is the best route for me following your chart. Thanks...
Post Reply