Asp是否像PHP一样支持Hash(bcrypt)密码

时间:2013-05-15 02:43:33

标签: php hash asp-classic cryptography hashcode

有没有办法在PHP中使用Hash(bcrypt)密码,就像在PHP中一样...以下是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() );

1 个答案:

答案 0 :(得分:0)

如果您的目标是在数据库中存储密码哈希,则可以使用SHA256。请在此处查看我的回答SHA256 with classic ASP

但别忘了使用盐!