本文整理汇总了PHP中Auth_OpenID_CryptUtil::randomString方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth_OpenID_CryptUtil::randomString方法的具体用法?PHP Auth_OpenID_CryptUtil::randomString怎么用?PHP Auth_OpenID_CryptUtil::randomString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Auth_OpenID_CryptUtil
的用法示例。
在下文中一共展示了Auth_OpenID_CryptUtil::randomString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: OpenID_MemcStore
function OpenID_MemcStore($prefix_part = null)
{
global $wgMemc, $wgDBname;
if (isset($prefix_part)) {
$this->prefix = $prefix_part . ':';
}
$auth_key = Auth_OpenID_CryptUtil::randomString($this->AUTH_KEY_LEN);
$k = $this->_authKeyKey();
$res = $wgMemc->add($k, $auth_key);
}
示例2: Auth_OpenID_mkNonce
function Auth_OpenID_mkNonce($when = null)
{
// Generate a nonce with the current timestamp
$salt = Auth_OpenID_CryptUtil::randomString(6, Auth_OpenID_Nonce_CHRS);
if ($when === null) {
$when = gmmktime();
}
$time_str = gmstrftime(Auth_OpenID_Nonce_TIME_FMT, $when);
return $time_str . $salt;
}
示例3: Auth_OpenID_mkNonce
function Auth_OpenID_mkNonce($when = null)
{
// Generate a nonce with the current timestamp
$salt = Auth_OpenID_CryptUtil::randomString(6, Auth_OpenID_Nonce_CHRS);
if ($when === null) {
// It's safe to call time() with no arguments; it returns a
// GMT unix timestamp on PHP 4 and PHP 5. gmmktime() with no
// args returns a local unix timestamp on PHP 4, so don't use
// that.
$when = time();
}
$time_str = gmstrftime(Auth_OpenID_Nonce_TIME_FMT, $when);
return $time_str . $salt;
}
示例4: generate_nonce
/**
* util function: current nonce
*/
private static function generate_nonce() {
$mt = microtime();
$rand = mt_rand();
$md5 = md5($mt . $rand);
$r = Auth_OpenID_CryptUtil::randomString(32,"abcdef01234567890");
//print '<h1>microtime:: '.$mt.' random:: '.$rand.' md5:: '.$md5.'</h1>';
return $r;// md5s look nicer than numbers
}
示例5: genAssoc
/**
* Generates an association with the specified parameters.
*/
function genAssoc($now, $issued = 0, $lifetime = 600)
{
$sec = Auth_OpenID_CryptUtil::randomString(20);
$hdl = Auth_OpenID_CryptUtil::randomString(128, $this->allowed_handle);
return new Auth_OpenID_Association($hdl, $sec, $now + $issued, $lifetime, 'HMAC-SHA1');
}
示例6: setUp
function setUp()
{
// Pre-compute DH with small prime so tests run quickly.
$this->server_dh = new Auth_OpenID_DiffieHellman(100389557, 2);
$this->consumer_dh = new Auth_OpenID_DiffieHellman(100389557, 2);
$lib =& Auth_OpenID_getMathLib();
$cls = $this->session_cls;
$this->consumer_session = new $cls($this->consumer_dh);
// base64(btwoc(g ^ xb mod p))
$this->dh_server_public = $lib->longToBase64($this->server_dh->public);
$this->secret = Auth_OpenID_CryptUtil::randomString($this->consumer_session->secret_size);
$this->enc_mac_key = base64_encode($this->server_dh->xorSecret($this->consumer_dh->public, $this->secret, $this->consumer_session->hash_func));
$this->msg = new Auth_OpenID_Message($this->message_namespace);
}
示例7: _createNonce
/**
* @access private
*/
function _createNonce()
{
$nonce = Auth_OpenID_CryptUtil::randomString($this->nonce_len, $this->nonce_chrs);
$this->store->storeNonce($nonce);
return $nonce;
}
示例8: getAuthKey
function getAuthKey()
{
$value = $this->_get_auth();
if (!$value) {
$auth_key = Auth_OpenID_CryptUtil::randomString($this->AUTH_KEY_LEN);
$auth_key_s = $this->blobEncode($auth_key);
$this->_create_auth($auth_key_s);
} else {
$auth_key_s = $value;
$auth_key = $this->blobDecode($auth_key_s);
}
$this->connection->commit();
if (strlen($auth_key) != $this->AUTH_KEY_LEN) {
$fmt = "Expected %d-byte string for auth key. Got key of length %d";
trigger_error(sprintf($fmt, $this->AUTH_KEY_LEN, strlen($auth_key)), E_USER_WARNING);
return null;
}
return $auth_key;
}
示例9: createAuthKey
/**
* Generate a new random auth key and safely store it in the
* location specified by $this->auth_key_name.
*
* @return string $key
*/
function createAuthKey()
{
if (!$this->active) {
trigger_error("FileStore no longer active", E_USER_ERROR);
return null;
}
$auth_key = Auth_OpenID_CryptUtil::randomString($this->AUTH_KEY_LEN);
list($file_obj, $tmp) = $this->_mktemp();
fwrite($file_obj, $auth_key);
fflush($file_obj);
fclose($file_obj);
if (function_exists('link')) {
// Posix filesystem
$saved = link($tmp, $this->auth_key_name);
Auth_OpenID_FileStore::_removeIfPresent($tmp);
} else {
// Windows filesystem
$saved = rename($tmp, $this->auth_key_name);
}
if (!$saved) {
// The link failed, either because we lack the permission,
// or because the file already exists; try to read the key
// in case the file already existed.
$auth_key = $this->readAuthKey();
}
return $auth_key;
}