本文整理匯總了PHP中Crypto::aes128cbcEncrypt方法的典型用法代碼示例。如果您正苦於以下問題:PHP Crypto::aes128cbcEncrypt方法的具體用法?PHP Crypto::aes128cbcEncrypt怎麽用?PHP Crypto::aes128cbcEncrypt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Crypto
的用法示例。
在下文中一共展示了Crypto::aes128cbcEncrypt方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: wrap
/**
* {@inheritDoc}
*/
public function wrap(array $in)
{
$encoded = $this->serializeAndTimestamp($in);
$cipherText = Crypto::aes128cbcEncrypt($this->cipherKey, $encoded);
$hmac = Crypto::hmacSha1($this->hmacKey, $cipherText);
$b64 = base64_encode($cipherText . $hmac);
return $b64;
}
示例2: testAes128
/**
* Tests Crypto::aes128cbcEncrypt()
*/
public function testAes128()
{
$string = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit';
$key = 'Aliquam erat volutpat';
$encrypted = Crypto::aes128cbcEncrypt($key, $string);
$decrypted = Crypto::aes128cbcDecrypt($key, $encrypted);
$this->assertEquals($decrypted, $string);
}
示例3: encrypt
public static function encrypt($key, $text)
{
if (extension_loaded('mcrypt')) {
return Crypto::aes128cbcEncrypt($key, $text);
}
$iv = substr(md5(uniqid(rand(), true)), 0, 8);
$blowfish = Crypt_Blowfish::factory('cbc', $key, $iv);
$encrypted = $blowfish->encrypt(base64_encode($text));
return $iv . $encrypted;
}
示例4: wrap
/**
* {@inheritDoc}
*/
public function wrap(array $in)
{
$encoded = $this->serializeAndTimestamp($in);
if (!function_exists('mcrypt_module_open') && $this->allowPlaintextToken) {
$cipherText = base64_encode($encoded);
} else {
$cipherText = Crypto::aes128cbcEncrypt($this->cipherKey, $encoded);
}
$hmac = Crypto::hmacSha1($this->hmacKey, $cipherText);
$b64 = base64_encode($cipherText . $hmac);
return $b64;
}