當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Crypt_AES類代碼示例

本文整理匯總了PHP中Crypt_AES的典型用法代碼示例。如果您正苦於以下問題:PHP Crypt_AES類的具體用法?PHP Crypt_AES怎麽用?PHP Crypt_AES使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Crypt_AES類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: AESDecrypt

function AESDecrypt($ciphertext, $key, $IV)
{
    $aes = new Crypt_AES(CRYPT_MODE_ECB);
    $aes->setKey(characet($key));
    $aes->setIV(characet($IV));
    return $aes->decrypt(hex2bin($ciphertext));
}
開發者ID:abcdlzy,項目名稱:webshell-manager,代碼行數:7,代碼來源:common.php

示例2: cipher

 private function cipher()
 {
     switch ($this->header['enc']) {
         case 'A128GCM':
         case 'A256GCM':
             throw new JOSE_Exception_UnexpectedAlgorithm('Algorithm not supported');
         case 'A128CBC-HS256':
         case 'A256CBC-HS512':
             $cipher = new Crypt_AES(CRYPT_AES_MODE_CBC);
             break;
         default:
             throw new JOSE_Exception_UnexpectedAlgorithm('Unknown algorithm');
     }
     switch ($this->header['enc']) {
         case 'A128GCM':
         case 'A128CBC-HS256':
             $cipher->setBlockLength(128);
             break;
         case 'A256GCM':
         case 'A256CBC-HS512':
             $cipher->setBlockLength(256);
             break;
         default:
             throw new JOSE_Exception_UnexpectedAlgorithm('Unknown algorithm');
     }
     return $cipher;
 }
開發者ID:nask0,項目名稱:jose,代碼行數:27,代碼來源:JWE.php

示例3: _pugpig_bbappworld_decrypt

function _pugpig_bbappworld_decrypt($base64_encrypted, $password)
{
    $cipher = new Crypt_AES(CRYPT_AES_MODE_ECB);
    // keys are null-padded to the closest valid size
    // longer than the longest key and it's truncated
    $cipher->setKey($password);
    return $cipher->decrypt(base64_decode($base64_encrypted));
}
開發者ID:shortlist-digital,項目名稱:agreable-pugpig-plugin,代碼行數:8,代碼來源:pugpig_subs_bbappword.php

示例4: decodeResponse

 protected function decodeResponse($received)
 {
     $aes = new Crypt_AES();
     $aes->setKey($this->key);
     $data = $aes->decrypt(base64_decode(substr($received, 28)));
     $decoder = new XmlrpcDecoder();
     return $decoder->decodeResponse($data);
 }
開發者ID:comodojo,項目名稱:rpcserver,代碼行數:8,代碼來源:XmlRpcEncryptedTransportTest.php

示例5: getApi

 /**
  * Returns an instance of the Crypto library
  * @return Crypt_AES
  */
 public function getApi()
 {
     if (is_null($this->api)) {
         $this->api = new AES();
         $this->api->setKey($this->getKey());
     }
     return $this->api;
 }
開發者ID:hhgr,項目名稱:hhgolf,代碼行數:12,代碼來源:Encrypt.php

示例6: decryptAES

 /**
  * Decrypt the provided data using AES cryptography with the provided key and IV
  *
  * @param string $data Data to decrypt
  * @param string $key Cipher key used to encrypt the data
  * @param string $iv IV used to encrypt the data
  * @param bool $base64Encoded Is the provided data Base64 encoded (defaults to true)
  * @return string Unencrypted data
  */
 public function decryptAES($data, $key, $iv, $base64Encoded = true)
 {
     $data = $base64Encoded ? base64_decode($data) : $data;
     $cipher = new \Crypt_AES();
     $cipher->setKey($key);
     $cipher->setIV($iv);
     $cipher->disablePadding();
     $decrypted = rtrim($cipher->decrypt($data));
     return $decrypted;
 }
開發者ID:ThemeSurgeon,項目名稱:launchkey-php,代碼行數:19,代碼來源:PhpSecLibCryptService.php

示例7: testKeyPaddingAES

 /**
  * @group github451
  */
 public function testKeyPaddingAES()
 {
     // same as the above - just with a different ciphertext
     $aes = new Crypt_AES();
     $aes->disablePadding();
     $aes->setKey(pack('H*', '2b7e151628aed2a6abf7158809cf4f3c762e7160'));
     // 160-bit key. AES should null pad to 192-bits
     $ciphertext = $aes->encrypt(pack('H*', '3243f6a8885a308d313198a2e0370734'));
     $this->assertEquals($ciphertext, pack('H*', 'c109292b173f841b88e0ee49f13db8c0'));
 }
開發者ID:TheTypoMaster,項目名稱:SPHERE-Framework,代碼行數:13,代碼來源:TestCase.php

示例8: create_message

 public function create_message(model\api_message $message)
 {
     $payload = serialize($message);
     $key = $this->key;
     $salt = crypt(microtime() . mt_rand(0, mt_getrandmax()));
     $cipher = new \Crypt_AES(CRYPT_AES_MODE_ECB);
     $cipher->setPassword($key, 'pbkdf2', 'sha256', $salt, 1000);
     $payload_enc = $cipher->encrypt($payload);
     $message = base64_encode(serialize(array('s' => $salt, 'p' => $payload_enc, 't' => @gmmktime())));
     return $message;
 }
開發者ID:SkyFire-Lee,項目名稱:x7chat,代碼行數:11,代碼來源:api.php

示例9: decrypt

 public static function decrypt($secret, $password, ApiKeyEncryptionOptions $options)
 {
     $decodedSecret = self::base64url_decode($secret);
     $salt = self::base64url_decode($options->getEncryptionKeySalt());
     $iterations = $options->getEncryptionKeyIterations();
     $keyLengthBits = $options->getEncryptionKeySize();
     $iv = substr($decodedSecret, 0, 16);
     $aes = new \Crypt_AES();
     $aes->setPassword($password, 'pbkdf2', 'sha1', $salt, $iterations, $keyLengthBits / 8);
     $aes->setKeyLength($keyLengthBits);
     $aes->setIV($iv);
     return $aes->decrypt(substr($decodedSecret, 16));
 }
開發者ID:InfinityCCS,項目名稱:stormpath-sdk-php,代碼行數:13,代碼來源:ApiKeyEncryptionUtils.php

示例10: loginWSAuthenticate

/**
 * Checks whether a user has the right to enter on the platform or not
 * @param string The username, as provided in form
 * @param string The cleartext password, as provided in form
 * @param string The WS URL, as provided at the beginning of this script
 */
function loginWSAuthenticate($username, $password, $wsUrl)
{
    // check params
    if (empty($username) or empty($password) or empty($wsUrl)) {
        return false;
    }
    // Create new SOAP client instance
    $client = new SoapClient($wsUrl);
    if (!$client) {
        return false;
    }
    // Include phpseclib methods, because of a bug with AES/CFB in mcrypt
    include_once api_get_path(LIBRARY_PATH) . 'phpseclib/Crypt/AES.php';
    // Define all elements necessary to the encryption
    $key = '-+*%$({[]})$%*+-';
    // Complete password con PKCS7-specific padding
    $blockSize = 16;
    $padding = $blockSize - strlen($password) % $blockSize;
    $password .= str_repeat(chr($padding), $padding);
    $cipher = new Crypt_AES(CRYPT_AES_MODE_CFB);
    $cipher->setKeyLength(128);
    $cipher->setKey($key);
    $cipher->setIV($key);
    $cipheredPass = $cipher->encrypt($password);
    // Mcrypt call left for documentation purposes - broken, see https://bugs.php.net/bug.php?id=51146
    //$cipheredPass = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $password,  MCRYPT_MODE_CFB, $key);
    // Following lines present for debug purposes only
    /*
    $arr = preg_split('//', $cipheredPass, -1, PREG_SPLIT_NO_EMPTY);
    foreach ($arr as $char) {
        error_log(ord($char));
    }
    */
    // Change to base64 to avoid communication alteration
    $passCrypted = base64_encode($cipheredPass);
    // The call to the webservice will change depending on your definition
    try {
        $response = $client->validateUser(array('user' => $username, 'pass' => $passCrypted, 'system' => 'chamilo'));
    } catch (SoapFault $fault) {
        error_log('Caught something');
        if ($fault->faultstring != 'Could not connect to host') {
            error_log('Not a connection problem');
            throw $fault;
        } else {
            error_log('Could not connect to WS host');
        }
        return 0;
    }
    return $response->validateUserResult;
}
開發者ID:KRCM13,項目名稱:chamilo-lms,代碼行數:56,代碼來源:login.ws.php

示例11: fileRead

function fileRead($key)
{
    $file = fopen("data.php", "r");
    $aes = new Crypt_AES();
    $aes->setKey($key);
    $tempdata = "";
    if ($file) {
        $tempdata = file_get_contents("data.php");
        $tempdata = substr($tempdata, strlen($GLOBALS["fileStart"]));
        $tempdata = $aes->decrypt(substr($tempdata, 0, -strlen($GLOBALS["fileEnd"])));
    }
    fclose($file);
    return $tempdata;
}
開發者ID:abcdlzy,項目名稱:webshell-manager,代碼行數:14,代碼來源:DataOperator.php

示例12: initAes

 protected function initAes($key, $iv, $keySize)
 {
     $this->aes = new \Crypt_AES();
     $this->aes->setKeyLength($keySize);
     $this->aesKey = $key;
     $this->aesIV = $iv;
     $this->aes->setKey($this->aesKey);
     $this->aes->setIV($this->aesIV);
 }
開發者ID:amegatron,項目名稱:cryptoapi,代碼行數:9,代碼來源:CryptoApiHelper.php

示例13: pac_message_receiver

 public function pac_message_receiver()
 {
     $content = Req::post("content");
     if (!isset($content)) {
         $this->returnXML("false", "S09", "返回報文為空");
     }
     $signature = Req::post("data_digest");
     if (!isset($signature)) {
         $this->returnXML("false", "S09", "返回報文為空");
     }
     Tiny::log("異步審批結果回執信息【content:" . $content . "】data_digest【" . $signature . "】");
     // 測試密鑰
     $aeskey = base64_decode($this->jkf['aes_key']);
     //AES解密,采用ECB模式
     $aes = new Crypt_AES(CRYPT_MODE_ECB);
     //設置AES密鑰
     $aes->setKey($aeskey);
     //解密AES密文
     $plaintext = $aes->decrypt(base64_decode($content));
     //測試rsa公鑰
     $publickey = $this->jkf['public_key'];
     $rsa = new Crypt_RSA();
     //設置RSA簽名模式 CRYPT_RSA_SIGNATURE_PSS or CRYPT_RSA_SIGNATURE_PKCS1
     $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
     //使用RSA公鑰驗證簽名
     $rsa->loadKey(base64_decode($publickey));
     //簽名通過
     if ($rsa->verify($plaintext, base64_decode($signature))) {
         $contentXML = simplexml_load_string($plaintext);
         $businessType = (string) $contentXML->head->businessType;
         $model = new GatewayModel();
         if ($businessType == "RESULT") {
             $model->insertResult($contentXML, "1");
         } else {
             if ($businessType == "PRODUCT_RECORD") {
                 $model->insertExamineResult($contentXML);
             }
         }
         $this->returnXML();
     } else {
         $this->returnXML("false", "S02", "非法的數字簽名");
     }
 }
開發者ID:sammychan1981,項目名稱:quanpin,代碼行數:43,代碼來源:gateway.php

示例14: attendance

 function attendance()
 {
     require_once 'AES.php';
     $aes = new Crypt_AES();
     $aes->setKey($this->site->conf['AESKey']);
     switch ($_GET['page'] ? $_GET['page'] : 00) {
         case 00:
             if ($this->site->userPermit == '3') {
                 $auth = base64_encode($aes->encrypt($_COOKIE['email'] . '	' . $_COOKIE['pass']));
                 setcookie('email', $_POST['email'], 0, '/');
                 setcookie('pass', md5($_POST['password']), 0, '/');
                 $team = $this->mysql->get_rows('SELECT * FROM `team` WHERE `active` = YEAR(CURDATE()) ORDER BY `name` ASC ');
                 foreach ($team as $key => $i) {
                     $list[] = array('<% ID %>' => $i['id'], '<% NAME %>' => $i['name']);
                 }
                 $ret = $this->templates->process_between('attendance.html', '<% STUDENTS %>', $list);
                 $ret = $this->templates->process($ret, array('<% AUTH %>' => $auth));
                 echo $this->templates->template('Team Attendance', array(), $ret);
             } else {
                 $this->site->home_page();
             }
             break;
         case 01:
             list($email, $pass) = explode('	', $aes->decrypt(base64_decode($_POST['auth'])));
             if ($this->site->checkCredentials($email, $pass) && $this->site->userPermit == '3') {
                 die("1");
             } else {
                 die("0");
             }
             break;
         case 02:
             $pass = $this->mysql->get_row('SELECT `password` FROM `team` WHERE `id` = ' . $_POST['id'] . ' LIMIT 1');
             if ($pass['password'] == md5($_POST['pass'])) {
                 $this->mysql->query("INSERT INTO `attendence` (`id`, `date`, `teamid`) VALUES (NULL, CURDATE(), '" . $_POST['id'] . "')");
                 die("1");
             }
             break;
     }
 }
開發者ID:ksiegel,項目名稱:FRC-CMS,代碼行數:39,代碼來源:team.php

示例15: decrypt_data

 public function decrypt_data($input_str, $key = SEC_STR)
 {
     $aes = new Crypt_AES();
     $aes->setKey($key);
     return $aes->decrypt($input_str);
 }
開發者ID:demenvil,項目名稱:BitScrow,代碼行數:6,代碼來源:bit-sci.lib.php


注:本文中的Crypt_AES類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。