コード例 #1
0
ファイル: BasicBlobCrypter.php プロジェクト: jkinner/ringside
 /**
  * {@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
0
 /**
  * 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
0
 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
0
 /**
  * {@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;
 }