Electronic Cookbook (ECB)
‣ CREATE A CORRUPT ENCRYPTED BLOCK
// The key size does not matter
$key = "1234567890";
// again: all padded to the blocksize
$message = "1111111122222222333333334444444455555555666666667777777788888888";
// Blowfish is an encryption that uses 64bit blocks
$crypted = mcrypt_encrypt(MCRYPT_BLOWFISH, $key, $message, MCRYPT_MODE_ECB);
// Lets "corrupt" a byte in the second block
$crypted[10] = "A";
// Decrypt, and see the results:
$plaintext = mcrypt_decrypt(MCRYPT_BLOWFISH, $key, $crypted, MCRYPT_MODE_ECB);
print $plaintext."\n";
woensdag 25 april 12