我已经用我自己的代码在php登录,现在我不那么擅长jquery ajax等等, 我的登录使用ajax jquery类型json,我把所有vals并将它们发布到服务器端的php,它会检查所有的细节,并通过相同的jquery ajax回复答案。使用ajax响应和哈希问题使用ajax响应和哈希问题使用jQuery的jQuery类型json
问题是我添加了nonce标记,在php中以mading形式登录表单,并且每次用户尝试登录nonce更改后,问题都是只有当我刷新登录页面时,nonce才更改为很好的nonce else将保持相同的nonce标记,并将发送不是更新的帖子,因为ajax在登录后没有刷新页面。
所以问题是我如何触发ajax在每次响应后刷新随机标记? nonce token是用php写的。
和有关散列随机数令牌,还有一点它使散列字符串的某个时候:
asdaskjn34kj + SDF/SD =
现在AJAX的jQuery自动删除“+”从哈希字符串,其这里给错误的标记在开机自检 我的散列函数:
public static function RandomBytes($count, $printable=FALSE)
{
$bytes = '';
// supress warnings when open_basedir restricts access to /dev/urand
if(@is_readable('/dev/urandom') && ($hRand = @fopen('/dev/urandom', 'rb')) !== FALSE)
{
$bytes = fread($hRand, $count);
fclose($hRand);
}
if((strlen($bytes) < $count) && function_exists('mcrypt_create_iv'))
{
// Use MCRYPT_RAND on Windows hosts with PHP < 5.3.7, otherwise use MCRYPT_DEV_URANDOM
// (http://bugs.php.net/55169).
if ((version_compare(PHP_VERSION, '5.3.7', '<') && strncasecmp(PHP_OS, 'WIN', 3) == 0))
$bytes = mcrypt_create_iv($count, MCRYPT_RAND);
else
$bytes = mcrypt_create_iv($count, MCRYPT_DEV_URANDOM);
}
if((strlen($bytes) < $count) && function_exists('openssl_random_pseudo_bytes')) // OpenSSL slow on Win
{
$bytes = openssl_random_pseudo_bytes($count);
}
if ((strlen($bytes) < $count) && @class_exists('COM'))
{
// Officially deprecated in Windows 7
// http://msdn.microsoft.com/en-us/library/aa388182%28v=vs.85%29.aspx
try
{
$CAPI_Util = new COM('CAPICOM.Utilities.1');
if(is_callable(array($CAPI_Util,'GetRandom')))
{
$bytes = $CAPI_Util->GetRandom(16,0);
$bytes = base64_decode($bytes);
}
}
catch (Exception $ex)
{
}
}
if (strlen($bytes) < $count)
{
// This fallback here based on phpass code
$bytes = '';
$random_state = microtime();
if (function_exists('getmypid'))
$random_state .= getmypid();
for ($i = 0; $i < $count; $i += 16) {
$random_state =
md5(microtime() . $random_state);
$bytes .=
pack('H*', md5($random_state));
}
$bytes = substr($bytes, 0, $count);
}
if ($printable)
return base64_encode($bytes);
else
return $bytes;
}
任何一个知道如何改变这种功能,使没有“+”字符串在hashesh?
在这里,我添加了你可以做的事情,在你的散列键中没有'+'。 –
这里我编辑了答案。 –