原文作者: suiphone
發表日期: 2004-12-29 15:15
原始連結: https://bbs.et8.net/bbs/showthread.php?t=616987
之前看到的, 紀錄一下, 程式部份為全部引用(稍微排版了一下)...
$key = $_REQUEST['key']; //Encrypt Function (編碼) function encrypt($encrypt) { global $key; $iv = mcrypt_create_iv(mcrypt_get_iv_size( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND); $passcrypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $encrypt, MCRYPT_MODE_ECB, $iv); $encode = base64_encode($passcrypt); return $encode; } //Decrypt Function (解碼) function decrypt($decrypt) { global $key; $decoded = base64_decode($decrypt); $iv = mcrypt_create_iv(mcrypt_get_iv_size( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND); $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $decoded, MCRYPT_MODE_ECB, $iv); return $decrypted; }
沒有留言:
張貼留言