本文整理汇总了PHP中Crypt_RSA::_parseKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Crypt_RSA::_parseKey方法的具体用法?PHP Crypt_RSA::_parseKey怎么用?PHP Crypt_RSA::_parseKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Crypt_RSA
的用法示例。
在下文中一共展示了Crypt_RSA::_parseKey方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: decrypting
function decrypting($paramCryptResponse)
{
$generatedPrivateKey = '';
$passPhrase = '';
$currentDir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
$currentDirParam = $currentDir . 'params.php';
$parentDirParam = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'params.php';
if (file_exists($parentDirParam)) {
include $parentDirParam;
} else {
if (file_exists($currentDirParam)) {
include $currentDirParam;
}
}
$rsa = new Crypt_RSA();
$rsa->setPassword($passPhrase);
$rsa->loadKey($generatedPrivateKey);
$rsa->setPassword();
$privatekey = $rsa->getPrivateKey();
$priv = $rsa->_parseKey($privatekey, CRYPT_RSA_PRIVATE_FORMAT_PKCS1);
require_once 'lib/bi2php/biRSA.php';
$keyDecrypt = new biRSAKeyPair('0', $priv['privateExponent']->toHex(), $priv['modulus']->toHex());
$decrypted = $keyDecrypt->biDecryptedString($paramCryptResponse);
if ($decrypted === false) {
return array(false, false);
}
$nlPos = strpos($decrypted, "\n");
$nlPos = $nlPos === false ? strlen($decrypted) : $nlPos;
$password = $keyDecrypt->biDecryptedString(substr($decrypted, 0, $nlPos));
$password = strlen($password) == 0 ? "f32b309d4759446fc81de858322ed391a0c167a0" : $password;
$challenge = substr($decrypted, $nlPos + 1);
return array($password, $challenge);
}
示例2: MySQLidb
require_once ABSPATH . 'db_config.php';
require_once ABSPATH . 'includes/autoload.php';
$db = new MySQLidb(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME, DB_PORT);
$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");
示例3: testDecryptJSGenerated
public function testDecryptJSGenerated()
{
$generatedKey = <<<EOL
-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEAxH7++yiHJUHEDU3wMw+FDfrlgOHNP+yiCFmYQPI0G7oj5uTy
tPMv3YVrEtb2Y62452C6WZcLSwOBqWlLUGfH0NJx35aaZG2CsUheNJEH+WEIFyel
mJmWDmwfZ6DnO+nsICylGWryDfgF7n4854mxa/SfI5bYAJD6x2D3o/NDwanlsbiU
B/ICKQmhZXvqNRRWdIEALasdLsDQ15MCfBTG1vKZqB9hiCFnZQEvrUKfWLdp6Uqa
j15QdEvTFopramsTkQHlOy/CnQDD7Qng8Qzqm7Ycq3Xz2R/nq5k/GeAnQdxKzW1j
QhktWfYrFQtxhyK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aCESHEPGeIHuo2LadLhwpnJjLmKKUL7
nDRDAoGADIHzuzFTYYgG4heLd2yXGv5+MDX+NmVzTr1j5dVOfzpiBJBjCN8Q9x3v
v9nNeZFIhPbhCTjCdY/NlcIHOZqUQulTu1DpDZ7zFO1Fs4aEDnBvp9i8yJquxhOQ
dBazzmZ3S/t2b6NtqClmn/1BgjgnKYURBn888UzbX6lqCNG3/mI=
-----END RSA PRIVATE KEY-----
EOL;
$enc = '8c87f3e5ef1021a764e80b92b3cf168130b8cb5c5b72016449bfb812da1718cc' . 'ea125dec512a9c91bfc336f35ea1804aafb2ef6b55c715a2fca2c90491d270bd' . '9a857bee7734bfef3252afac67cb3a6c8dcc9168164a44a9c8f31001289077ef' . '3e493d4581cdb94c7812140d1ebca802636cf16cdc5fe48128f758094ebe64fe' . '4b7fb1fb814c8502e1c52fcd9cbc3431a7fc8f3f8dda146eef15b4d14192f444' . '6b9cff5bd8c3f2c8ba90b00ab93263182ad3ed7ad0d460cc02529826c6048091' . '1c712d6e212ced1a7f5fc18a1574fdceb101f28d13cd106e8d04a24de9ab3570' . '77fee33e168b584a1cbf6ea27de9e88a89e1616b18897cd7288d2a02c62434a7';
$rsa = new Crypt_RSA();
$rsa->loadKey($generatedKey);
$keyComp = $rsa->_parseKey($rsa->getPrivateKey(), CRYPT_RSA_PRIVATE_FORMAT_PKCS1);
$keyDecrypt = new biRSAKeyPair('0', $keyComp['privateExponent']->toHex(), $keyComp['modulus']->toHex());
$decrypted = $keyDecrypt->biDecryptedString($enc);
$this->assertEquals("1234OhmyGOD#", $decrypted, "Decrypt from JavaScript encripted date.");
}
示例4: checkForFileMakerMedia
/**
* @param $dbProxyInstance
* @param $options
* @param $file
* @param $isURL
* @return array
*/
public function checkForFileMakerMedia($dbProxyInstance, $options, $file, $isURL)
{
if (strpos($file, "/fmi/xml/cnt/") === 0) {
// FileMaker's container field storing an image.
if (isset($options['authentication']['user'][0]) && $options['authentication']['user'][0] == 'database_native') {
$passPhrase = '';
$generatedPrivateKey = '';
// avoid errors for defined in params.php.
$currentDir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
$currentDirParam = $currentDir . 'params.php';
$parentDirParam = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'params.php';
if (file_exists($parentDirParam)) {
include $parentDirParam;
} else {
if (file_exists($currentDirParam)) {
include $currentDirParam;
}
}
$rsa = new Crypt_RSA();
$rsa->setPassword($passPhrase);
$rsa->loadKey($generatedPrivateKey);
$rsa->setPassword();
$privatekey = $rsa->getPrivateKey();
$priv = $rsa->_parseKey($privatekey, CRYPT_RSA_PRIVATE_FORMAT_PKCS1);
require_once 'lib/bi2php/biRSA.php';
$keyDecrypt = new biRSAKeyPair('0', $priv['privateExponent']->toHex(), $priv['modulus']->toHex());
$cookieNameUser = '_im_username';
$cookieNamePassword = '_im_credential';
$credential = isset($_COOKIE[$cookieNameUser]) ? urlencode($_COOKIE[$cookieNameUser]) : '';
if (isset($_COOKIE[$cookieNamePassword])) {
$credential .= ':' . urlencode($keyDecrypt->biDecryptedString($_COOKIE[$cookieNamePassword]));
}
$urlHost = $dbProxyInstance->dbSettings->getDbSpecProtocol() . '://' . $credential . '@' . $dbProxyInstance->dbSettings->getDbSpecServer() . ':' . $dbProxyInstance->dbSettings->getDbSpecPort();
} else {
$urlHost = $dbProxyInstance->dbSettings->getDbSpecProtocol() . "://" . urlencode($dbProxyInstance->dbSettings->getDbSpecUser()) . ":" . urlencode($dbProxyInstance->dbSettings->getDbSpecPassword()) . "@" . $dbProxyInstance->dbSettings->getDbSpecServer() . ":" . $dbProxyInstance->dbSettings->getDbSpecPort();
}
$file = $urlHost . str_replace(" ", "%20", $file);
foreach ($_GET as $key => $value) {
if ($key !== 'media' && $key !== 'attach') {
$file .= "&" . urlencode($key) . "=" . urlencode($value);
}
}
$isURL = true;
return array($file, $isURL);
}
return array($file, $isURL);
}
示例5: processingRequest
/**
* @param $options
* @param null $access
* @param bool $bypassAuth
*/
function processingRequest($options, $access = null, $bypassAuth = false)
{
$this->logger->setDebugMessage("[processingRequest]", 2);
$this->outputOfPrcessing = '';
$generatedPrivateKey = '';
$passPhrase = '';
$currentDir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
$currentDirParam = $currentDir . 'params.php';
$parentDirParam = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'params.php';
if (file_exists($parentDirParam)) {
include $parentDirParam;
} else {
if (file_exists($currentDirParam)) {
include $currentDirParam;
}
}
$messageClass = null;
if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
$clientLangArray = explode(',', $_SERVER["HTTP_ACCEPT_LANGUAGE"]);
foreach ($clientLangArray as $oneLanguage) {
$langCountry = explode(';', $oneLanguage);
if (strlen($langCountry[0]) > 0) {
$clientLang = explode('-', $langCountry[0]);
$messageClass = "MessageStrings_{$clientLang['0']}";
if (file_exists("{$currentDir}{$messageClass}.php")) {
$messageClass = new $messageClass();
break;
}
}
$messageClass = null;
}
}
if ($messageClass == null) {
$messageClass = new MessageStrings();
}
$tableInfo = $this->dbSettings->getDataSourceTargetArray();
$access = is_null($access) ? $_POST['access'] : $access;
$clientId = isset($_POST['clientid']) ? $_POST['clientid'] : (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : "Non-browser-client");
$this->paramAuthUser = isset($_POST['authuser']) ? $_POST['authuser'] : "";
$paramResponse = isset($_POST['response']) ? $_POST['response'] : "";
$this->dbSettings->setRequireAuthentication(false);
$this->dbSettings->setRequireAuthorization(false);
$this->dbSettings->setDBNative(false);
$keywordAuth = $access == "select" ? "load" : $access;
if (isset($options['authentication']) || $access == 'challenge' || $access == 'changepassword' || isset($tableInfo['authentication']) && (isset($tableInfo['authentication']['all']) || isset($tableInfo['authentication'][$keywordAuth]))) {
$this->dbSettings->setRequireAuthorization(true);
$this->dbSettings->setDBNative(false);
if (isset($options['authentication']['user']) && $options['authentication']['user'][0] == 'database_native') {
$this->dbSettings->setDBNative(true);
}
}
// $this->logger->setDebugMessage("dbNative={$this->dbSettings->isDBNative()}", 2);
// $this->logger->setDebugMessage("", 2);
if (!$bypassAuth && $this->dbSettings->getRequireAuthorization()) {
// Authentication required
if (strlen($this->paramAuthUser) == 0 || strlen($paramResponse) == 0) {
// No username or password
$access = "do nothing";
$this->dbSettings->setRequireAuthentication(true);
}
// User and Password are suppried but...
if ($access != 'challenge') {
// Not accessing getting a challenge.
if ($this->dbSettings->isDBNative()) {
$rsa = new Crypt_RSA();
$rsa->setPassword($passPhrase);
$rsa->loadKey($generatedPrivateKey);
$rsa->setPassword();
$privatekey = $rsa->getPrivateKey();
$priv = $rsa->_parseKey($privatekey, CRYPT_RSA_PRIVATE_FORMAT_PKCS1);
require_once 'bi2php/biRSA.php';
$keyDecrypt = new biRSAKeyPair('0', $priv['privateExponent']->toHex(), $priv['modulus']->toHex());
$decrypted = $keyDecrypt->biDecryptedString($paramResponse);
// $this->logger->setDebugMessage("decrypted={$decrypted}", 2);
if ($decrypted !== false) {
$nlPos = strpos($decrypted, "\n");
$nlPos = $nlPos === false ? strlen($decrypted) : $nlPos;
$password = $keyDecrypt->biDecryptedString(substr($decrypted, 0, $nlPos));
$password = strlen($password) == 0 ? "f32b309d4759446fc81de858322ed391a0c167a0" : $password;
$challenge = substr($decrypted, $nlPos + 1);
// $this->logger->setDebugMessage("password={$password}", 2);
// $this->logger->setDebugMessage("paramAuthUser={$this->paramAuthUser}", 2);
if (!$this->checkChallenge($challenge, $clientId)) {
$access = "do nothing";
$this->dbSettings->setRequireAuthentication(true);
} else {
$this->dbSettings->setUserAndPasswordForAccess($this->paramAuthUser, $password);
$this->logger->setDebugMessage("[checkChallenge] returns true.", 2);
}
} else {
$this->logger->setDebugMessage("Can't decrypt.");
$access = "do nothing";
$this->dbSettings->setRequireAuthentication(true);
}
} else {
//.........这里部分代码省略.........