Example #1
0
File: Rsa.php Project: wuxw/YYF
 /**
  * 生成和保存密钥对
  * @method init
  * @param  boolean $return_pri [返回公钥或者私钥]
  * @return [string]              [公钥或者私钥]
  * @author NewFuture
  */
 private static function init($return_pri = false)
 {
     $res = openssl_pkey_new();
     openssl_pkey_export($res, $pri);
     $d = openssl_pkey_get_details($res);
     $pub = $d['key'];
     $time = time() + Config::get('rsa.lifetime') ?: 604800;
     kv::set('RSA_life_time', $time);
     kv::set('RSA_pri_key', $pri);
     Kv::set('RSA_pub_key', $pub);
     return $return_pri ? $pri : $pub;
 }
Example #2
0
//$Servers = [
//	'127.0.0.1:11211', 'localhost:11211', '127.0.0.1'
//];
$Servers = '127.0.0.1:11211;localhost:11211;127.0.0.1';
try {
    $KV = new kv(array('Enabled' => false), array('Enabled' => true, 'Servers' => $Servers));
} catch (Exception $E) {
    echo $E->getMessage();
}
// Object style
$KV['Value1'] = 'asdf';
echo $KV['Value1'];
// Outputs "asdf"
echo '<hr />';
// Static class style
echo kv::get('Value1');
// Outputs "asdf";
echo '<hr />';
kv::set('Value1', 'qwerty');
echo kv::get('Value1');
// Outputs "qwerty";
echo '<hr />';
kv::clear_all();
echo kv::get('Value1');
// Outputs "";
echo '<hr />';
kv::set('TestNumber', 42);
echo $KV['TestNumber'];
echo '<hr />';
kv::inc('TestNumber', 2);
echo $KV['TestNumber'];