本文整理汇总了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;
}