예제 #1
0
function getunencryptpass($encryptpassword)
{
    $encryptpassword = @base64_encode(pack("H*", $encryptpassword));
    $decodedpassword = privatekey_decodeing($encryptpassword, RSA_KEY_ADD, TRUE);
    $decodedpassword = trim($decodedpassword);
    return $decodedpassword;
}
예제 #2
0
<?php

require "../rsa/rsa.php";
session_start();
//启用session
$userPoint = 0;
$userPoint = $_POST["userPoint"];
//echo "密文:$userPoint";
$userPoint = base64_encode(pack("H*", $userPoint));
$userPoint = privatekey_decodeing($userPoint, $prikey, true);
//echo "解析:$userPoint";
if (preg_match('/^\\d+$/i', $userPoint)) {
    $_SESSION["userPoint"] = $userPoint;
    echo "You get " . $userPoint . " point !";
} else {
    $_SESSION["userPoint"] = 0;
    echo "You try to hack the game , f**k your mather !";
}
예제 #3
0
파일: new1.php 프로젝트: lcylp/wamp
* @param string 密钥文件(.pem)
* @param string 密文是否来源于JS的RSA加密
* @return string 明文
*/
function privatekey_decodeing($crypttext, $fileName, $fromjs = FALSE)
{
    $key_content = file_get_contents($fileName);
    $prikeyid = openssl_get_privatekey($key_content);
    $crypttext = base64_decode($crypttext);
    $padding = $fromjs ? OPENSSL_NO_PADDING : OPENSSL_PKCS1_PADDING;
    if (openssl_private_decrypt($crypttext, $sourcestr, $prikeyid, $padding)) {
        return $fromjs ? rtrim(strrev($sourcestr), "/0") : "" . $sourcestr;
    }
    return FALSE;
}
define("PEM", "private_key.pem");
//私钥文件
$data = $_POST["name"];
//$data='try';
$txt_en = base64_encode(pack("H*", $data));
//转成base64格式
$txt_de = privatekey_decodeing($txt_en, PEM, TRUE);
var_dump($txt_de);
setcookie("ceshi", $txt_de, time() + 3600);
echo $txt_de;
?>