/** * @group github451 */ public function testKeyPaddingRijndael() { // this test case is from the following URL: // https://web.archive.org/web/20070209120224/http://fp.gladman.plus.com/cryptography_technology/rijndael/aesdvec.zip $aes = new Crypt_Rijndael(); $aes->disablePadding(); $aes->setKey(pack('H*', '2b7e151628aed2a6abf7158809cf4f3c762e7160')); // 160-bit key. Valid in Rijndael. $ciphertext = $aes->encrypt(pack('H*', '3243f6a8885a308d313198a2e0370734')); $this->assertEquals($ciphertext, pack('H*', '231d844639b31b412211cfe93712b880')); }
function osc_decrypt_alert($string) { $key = hash("sha256", osc_get_alert_private_key(), true); if(function_exists('mcrypt_module_open')) { $cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_256, '', MCRYPT_MODE_CBC, ''); $cipherText = ''; if (mcrypt_generic_init($cipher, $key, $key) != -1) { $cipherText = mdecrypt_generic($cipher, $string); mcrypt_generic_deinit($cipher); } return trim(substr($cipherText, 32)); }; require_once LIB_PATH . 'phpseclib/Crypt/Rijndael.php'; $cipher = new Crypt_Rijndael(CRYPT_RIJNDAEL_MODE_CBC); $cipher->disablePadding(); $cipher->setBlockLength(256); $cipher->setKey($key); $cipher->setIV($key); return trim(substr($cipher->decrypt($string), 32)); }