当前位置: 首页>>代码示例>>PHP>>正文


PHP Crypt_AES::setKey方法代码示例

本文整理汇总了PHP中Crypt_AES::setKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Crypt_AES::setKey方法的具体用法?PHP Crypt_AES::setKey怎么用?PHP Crypt_AES::setKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Crypt_AES的用法示例。


在下文中一共展示了Crypt_AES::setKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: _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

示例5: 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

示例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: 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

示例9: 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

示例10: initSymmetric

 /**
  * Initializes AES instance using either provided $options or session values
  * @param array $options Array of options, containing 'key' and 'iv' values
  * @return mixed|void
  * @throws Exception
  */
 public function initSymmetric($options = array())
 {
     if (empty($options) && Session::has('aes_key') && Session::has('aes_iv')) {
         $options = array('key' => Session::get('aes_key'), 'iv' => Session::get('aes_iv'));
     }
     if (!(isset($options['key']) && isset($options['iv']))) {
         \Log::error("Either key or iv not set");
         throw new \Exception("Either key or iv not set");
     }
     Session::put('aes_key', $options['key']);
     Session::put('aes_iv', $options['iv']);
     $aes = new \Crypt_AES(CRYPT_AES_MODE_CBC);
     $aes->setKeyLength(256);
     $aes->setKey(Base64::UrlDecode($options['key']));
     $aes->setIV(Base64::UrlDecode($options['iv']));
     $aes->enablePadding();
     $this->aes = $aes;
     $this->isAesInitialized = true;
 }
开发者ID:tiagogoddard,项目名称:cryptoapi,代码行数:25,代码来源:RsaAesCryptography.php

示例11: 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

示例12: 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

示例13: array

$param = array();
$param['nopass']['x'] = 176;
$param['nopass']['y'] = 100;
$param['nopass']['width'] = 100;
$param['nopass']['bg_path'] = ABSPATH . 'img/k_bg.png';
$param['pass']['x'] = 167;
$param['pass']['y'] = 93;
$param['pass']['width'] = 118;
$param['pass']['bg_path'] = ABSPATH . 'img/k_bg_pass.png';
$rsa = new Crypt_RSA();
extract($rsa->createKey(2048));
$publickey = clear_public_key($publickey);
$priv = $rsa->_parseKey($privatekey, CRYPT_RSA_PRIVATE_FORMAT_PKCS1);
if (!empty($_REQUEST['password'])) {
    $aes = new Crypt_AES(CRYPT_AES_MODE_ECB);
    $aes->setKey(md5($_REQUEST['password']));
    $text = $privatekey;
    $aes_encr = $aes->encrypt($text);
    $private_key = chunk_split(base64_encode($aes_encr), 64);
    $param = $param['pass'];
    $k_bg_path = ABSPATH . 'img/k_bg.png';
} else {
    $private_key = str_replace(array('-----BEGIN RSA PRIVATE KEY-----', '-----END RSA PRIVATE KEY-----'), '', $privatekey);
    $param = $param['nopass'];
}
$iPod = stripos($_SERVER['HTTP_USER_AGENT'], "iPod");
$iPhone = stripos($_SERVER['HTTP_USER_AGENT'], "iPhone");
$iPad = stripos($_SERVER['HTTP_USER_AGENT'], "iPad");
if ($iPod || $iPhone || $iPad) {
    $gd = key_to_img($private_key, $param, $_SESSION['user_id']);
    header('Content-Disposition: attachment; filename="Dcoin-private-key-' . $_SESSION['user_id'] . '.png"');
开发者ID:scuba323,项目名称:dcoin,代码行数:31,代码来源:Dcoin-key.php

示例14: urlencode

$url = "{$host}/get_tx.php";
debug_print($url, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
// загружаем сами тр-ии
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'data=' . urlencode($encrypted_data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$encrypted_tx_set = curl_exec($ch);
curl_close($ch);
debug_print('$encrypted_tx_set=' . $encrypted_tx_set, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
debug_print('$my_key=' . $my_key, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
$aes = new Crypt_AES();
$aes->setKey($my_key);
// теперь в $binary_tx будут обычные тр-ии
$binary_tx = $aes->decrypt($encrypted_tx_set);
unset($aes);
debug_print('$binary_tx=' . $binary_tx, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
// разберем полученные тр-ии
do {
    $tx_size = ParseData::decode_length($binary_tx);
    $tx_binary_data = ParseData::string_shift($binary_tx, $tx_size);
    debug_print('$tx_binary_data=' . $tx_binary_data, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
    list(, $tx_hex) = unpack("H*", $tx_binary_data);
    if (!$tx_binary_data) {
        continue;
    }
    // проверим размер
    if (strlen($tx_binary_data) > $variables['max_tx_size']) {
开发者ID:scuba323,项目名称:dcoin,代码行数:31,代码来源:gate_hashes.php

示例15: hash

 if (preg_match('#isEmpty = TRUE;#', $line)) {
     $oldPassphrase = 'isEmpty = TRUE;';
     $newPassphrase = hash('sha512', md5(str_shuffle(time())));
     if (is_writable("../.ssh/passphrase")) {
         $handle = fopen('../.ssh/passphrase', 'w');
         fwrite($handle, $newPassphrase);
         fclose($handle);
     }
     //---------------------------------------------------------+
     require_once "../libs/phpseclib/Crypt/AES.php";
     $aes = new Crypt_AES();
     $aes->setKeyLength(256);
     //---------------------------------------------------------+
     $boxes = mysql_query("SELECT `boxid`, `password` FROM `" . DBPREFIX . "box`");
     while ($rowsBoxes = mysql_fetch_assoc($boxes)) {
         $aes->setKey($oldPassphrase);
         $password = $aes->decrypt($rowsBoxes['password']);
         $aes->setKey($newPassphrase);
         $password = $aes->encrypt($password);
         query_basic("UPDATE `" . DBPREFIX . "box` SET `password` = '" . mysql_real_escape_string($password) . "' WHERE `boxid` = '" . $rowsBoxes['boxid'] . "'");
         unset($password);
     }
     unset($boxes);
 }
 unset($line);
 //---------------------------------------------------------+
 //Updating structure for table "log"
 query_basic("ALTER TABLE `" . DBPREFIX . "log` ADD `scriptid` int(8) UNSIGNED NULL");
 //---------------------------------------------------------+
 //Updating structure for table "script"
 query_basic("ALTER TABLE `" . DBPREFIX . "script` CHANGE `daemon` `type` int(1) NOT NULL ");
开发者ID:404rq,项目名称:bgpanel,代码行数:31,代码来源:update_030_to_035.php


注:本文中的Crypt_AES::setKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。