一个VB.NET密码哈希函数的等价物 [英] A PHP equivalent for a VB.NET password hash function

查看:176
本文介绍了一个VB.NET密码哈希函数的等价物的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下Visual Basic .NET函数用于生成存储在内部数据库中的密码哈希值:

 公共函数HashPassword(ByVal密码作为字符串,ByVal盐作为字符串)作为字符串
昏暗pwd作为字符串=密码& Salt
Dim hasher As New Security.Cryptography.SHA256Managed()
Dim pwdb As Byte()= System.Text.Encoding.UTF8.GetBytes(pwd)
Dim pwdh As Byte()= hasher.ComputeHash(pwdb)
返回Convert.ToBase64String(pwdh)
End Function

我需要帮助创建一个与上述函数相当的PHP:

示例:

 假设密码字符串为:warn 
盐值为:i< | Xf:n_y_YrLor`qAA] .QK(2C8AJ:Z\f& amp; ; TC7bi = Acw_.w |
返回的哈希应该是:0Yq3gR09U1GKfFRzmRxdJXK5jSQowHp / YLGA88p0s18 =

我无法复制PHP中的散列。



亲切的问候,



Voxinator

解决方案

第一个链接在google中:( p> www.php.net/manual/en/function.hash.phprel =nofollow> http://www.php.net/manual/en/function.hash.php with sha256
http://www.php.net/manual/en/ function.base64-encode.php

  $ pwd ='warn'; 
$ salt ='i <| Xf:n_y_YrLor`qAA.QK(2C8AJ:Z\f& TC7bi = Acw_.w |';
$ pwd。= $ salt;
$ r1 = hash('sha256',$ pwd,true); //二进制散列
$ r2 = base64_encode($ r1); // base64表示
echo $ r2;

输出

  0Yq3gR09U1GKfFRzmRxdJXK5jSQowHp / YLGA88p0s18 = 


I have the following Visual Basic .NET function that is used to generate password hashes that are stored in an internal database:

Public Function HashPassword(ByVal Password As String, ByVal Salt As String) As String
    Dim pwd As String = Password & Salt
    Dim hasher As New Security.Cryptography.SHA256Managed()
    Dim pwdb As Byte() = System.Text.Encoding.UTF8.GetBytes(pwd)
    Dim pwdh As Byte() = hasher.ComputeHash(pwdb)
    Return Convert.ToBase64String(pwdh)
End Function

I need help creating a PHP equivalent of the above function:

Example:

Assuming a password string of: warn
A salt value of: i<|Xf":n_y_Yr"Lor`qAA].QK(2C8AJ:Z"\f&TC7bi=Acw_.w|
The returned hash should be: 0Yq3gR09U1GKfFRzmRxdJXK5jSQowHp/YLGA88p0s18=

I'm having trouble replicating the hash in PHP.

Kind Regards,

Voxinator

解决方案

first links in google :(

http://www.php.net/manual/en/function.hash.php with sha256 http://www.php.net/manual/en/function.base64-encode.php

$pwd = 'warn';
$salt = 'i<|Xf":n_y_Yr"Lor`qAA].QK(2C8AJ:Z"\f&TC7bi=Acw_.w|';
$pwd .= $salt;
$r1 = hash('sha256', $pwd, true); // binary hash
$r2 = base64_encode($r1); // base64 representation
echo $r2;

output

0Yq3gR09U1GKfFRzmRxdJXK5jSQowHp/YLGA88p0s18=

这篇关于一个VB.NET密码哈希函数的等价物的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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