【发布时间】:2013-05-21 17:10:42
【问题描述】:
有没有办法像在 PHP 中一样在 ASP 中使用 Hash (bcrypt) 密码...以下是 PHP 的代码,但 ASP 的替代方案是什么...... ASP 支持 Hash(bcrypt) 还是有其他方法可以做?请用这种情况启发我......
PHP 会是
$link = mysql_connect('localhost', 'wpscanner', 'aUvmxcxvTUPtW8Kw')
or die('Not connected : ' . mysql_error());
mysql_select_db('wpscanner', $link)
or die ('Not selected : ' . mysql_error());
$password = mysql_real_escape_string($_GET['password']);
$email = mysql_real_escape_string($_GET['email']);
//This string tells crypt to use blowfish for 5 rounds.
$Blowfish_Pre = '$2a$05$';
$Blowfish_End = '$';
注册用户需要的PHP代码
// Blowfish accepts these characters for salts.
$Allowed_Chars =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./';
$Chars_Len = 63;
// 18 would be secure as well.
$Salt_Length = 21;
$mysql_date = date( 'Y-m-d' );
$salt = "";
for($i=0; $i<$Salt_Length; $i++)
{
$salt .= $Allowed_Chars[mt_rand(0,$Chars_Len)];
}
$bcrypt_salt = $Blowfish_Pre . $salt . $Blowfish_End;
$hashed_password = crypt($password, $bcrypt_salt);
$sql = 'INSERT INTO users (reg_date, email, salt, password) ' .
"VALUES ('$mysql_date', '$email', '$salt', '$hashed_password')";
mysql_query($sql) or die( mysql_error() );
【问题讨论】:
-
是的..它在here
-
谢谢,但那是用于 c# 中的 asp.net,我希望它用于 VB 中的 asp classic。任何建议...
-
对不起。您没有指定您使用的语言。 ASP.NET 并非一直都在使用 VB
标签: php hash asp-classic cryptography hashcode