请问ASP支持哈希(bcrypt)密码就像在PHP [英] Does Asp support Hash (bcrypt) Passwords like in PHP

查看:186
本文介绍了请问ASP支持哈希(bcrypt)密码就像在PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用哈希(bcrypt)在ASP密码像PHP ...以下将是code PHP的一个方式,但什么是ASP替代..是相同的,只是改变的事情周围?做ASP支持哈希(bcrypt),或者是有其他的方式呢?请engliten我这种情况...

PHP会

  $链接= mysql_connect('localhost'的,'wpscanner','aUvmxcxvTUPtW8Kw')
    或死亡(未连接:'mysql_error());
mysql_select_db('wpscanner',$链接)
    或死亡(不选择:mysql_error());$密码= mysql_real_escape_string($ _ GET ['密码']);
$电子邮件= mysql_real_escape_string($ _ GET ['邮件']);//这个字符串告诉隐窝使用河豚5轮。
$ Blowfish_ pre ='$ 2A $ 05 $';
$ Blowfish_End =$;

PHP code,你需要注册一个用户。

  //河豚接受这些字符盐。
$ Allowed_Chars =
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./';
$ Chars_Len = 63;// 18是安全的为好。
$ Salt_Length = 21;$ mysql_date =日期('Y-M-D');
$盐=;为($ I = 0; $ I< $ Salt_Length; $ I ++)
{
    $盐= $ Allowed_Chars [mt_rand(0,$ Chars_Len)〕。
}
$ bcrypt_salt = $ Blowfish_ pre。 $盐。 $ Blowfish_End;$ hashed_pa​​ssword =隐窝($的密码,$ bcrypt_salt);$的SQL =INSERT INTO用户(reg_date,电子邮件,盐,密码)。
  VALUES('$ mysql_date,$电子邮件,$盐','$ hashed_pa​​ssword');的mysql_query($的SQL)或死亡(mysql_error());


解决方案

如果你的目标是在一个数据库中存储密码的哈希值,你可以使用SHA256。见我的答案在这里<一个href=\"http://stackoverflow.com/questions/14126243/hash-hmac-in-using-pure-classic-asp/14154244#14154244\">SHA256与传统的ASP

但不要忘了用的盐!

Is there a way to use Hash (bcrypt) Passwords in ASP like in PHP... the following would be the code for PHP but what is the alternative for ASP .. is it the same and just change things around? does ASP support Hash(bcrypt) or is there other way to do ? please engliten me with this situation...

PHP would be

$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 code you need to register a user

// 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() );

解决方案

If your goal is storing a hash of a password in a database, you could use SHA256. See my answer here SHA256 with classic ASP

But don't forget to use a salt!

这篇关于请问ASP支持哈希(bcrypt)密码就像在PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆