Does Asp support Hash (bcrypt) Passwords like in PHP -
is there way use hash (bcrypt) passwords in asp in php... following code php alternative asp .. same , change things around? asp support hash(bcrypt) or there other way ? please engliten me situation...
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 use blowfish 5 rounds. $blowfish_pre = '$2a$05$'; $blowfish_end = '$';
php code need register user
// blowfish accepts these characters salts. $allowed_chars = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789./'; $chars_len = 63; // 18 secure 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 users (reg_date, email, salt, password) ' . "values ('$mysql_date', '$email', '$salt', '$hashed_password')"; mysql_query($sql) or die( mysql_error() );
if goal storing hash of password in database, use sha256. see answer here sha256 classic asp
but don't forget use salt!
Comments
Post a Comment