3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php /* 128-bit key = 01 23 45 67 12 34 56 78 23 45 67 89 34 56 78 9A plaintext = 01 23 45 67 89 AB CD EF ciphertext = 23 8B 4F E5 84 7E 44 B2 */ $key = "\x01\x23\x45\x67\x12\x34\x56\x78\x23\x45\x67\x89\x34\x56\x78\x9A"; $data = "\x01\x23\x45\x67\x89\xAB\xCD\xEF"; var_dump(mcrypt_encrypt('cast-128', $key, $data, 'ecb') === "\x23\x8B\x4F\xE5\x84\x7E\x44\xB2"); /* 80-bit key = 01 23 45 67 12 34 56 78 23 45 = 01 23 45 67 12 34 56 78 23 45 00 00 00 00 00 00 plaintext = 01 23 45 67 89 AB CD EF ciphertext = EB 6A 71 1A 2C 02 27 1B */ $key = "\x01\x23\x45\x67\x12\x34\x56\x78\x23\x45"; $data = "\x01\x23\x45\x67\x89\xAB\xCD\xEF"; $key .= "\x00\x00\x00\x00\x00\x00"; var_dump(mcrypt_encrypt('cast-128', $key, $data, 'ecb') === "\xEB\x6A\x71\x1A\x2C\x02\x27\x1B"); /* 40-bit key = 01 23 45 67 12 = 01 23 45 67 12 00 00 00 00 00 00 00 00 00 00 00 plaintext = 01 23 45 67 89 AB CD EF ciphertext = 7A C8 16 D1 6E 9B 30 2E */ $key = "\x01\x23\x45\x67\x12"; $data = "\x01\x23\x45\x67\x89\xAB\xCD\xEF"; $key .= "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; var_dump(mcrypt_encrypt('cast-128', $key, $data, 'ecb') === "\x7A\xC8\x16\xD1\x6E\x9B\x30\x2E");
Output for 7.0.6 - 7.1.0
Fatal error: Uncaught Error: Call to undefined function mcrypt_encrypt() in /in/7amfr:10 Stack trace: #0 {main} thrown in /in/7amfr on line 10
Process exited with code 255.
Output for 5.4.36 - 5.5.34, 5.6.7 - 5.6.20, 7.0.0 - 7.0.5
bool(true) bool(false) bool(false)
Output for 5.0.0 - 5.4.35, 5.5.35, 5.6.21 - 5.6.28
Fatal error: Call to undefined function mcrypt_encrypt() in /in/7amfr on line 10
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: mcrypt_encrypt() in /in/7amfr on line 10
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: mcrypt_encrypt() in /in/7amfr on line 10
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: mcrypt_encrypt() in /in/7amfr on line 10