哈希密码 [英] hashing passwords

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

问题描述




我正在使用MD5来哈希我的密码并将它们作为哈希值添加到数据库中。

我注意到有些密码不是'没有得到认可,我认为这是因为哈希可能会在我的

密码中引入一些字符,这些字符在SQL服务器无法正确处理时会发生。


例如,密码''startreck''工作正常

密码''测试''没有


任何人都知道如何我可以解决这个问题吗?


任何帮助都将非常感谢

Dino


-

--------------------------------------------- ----------------------------

反击垃圾邮件!

下载Spam Inspector,屡获殊荣的反垃圾邮件过滤器
http://mail.giantcompany.com

Hi,

I am using MD5 to hash my passwords and add them to database as hashed.
I have noticed though that some passwords don''t get recognized and I suppose
that it happen because hashing might introduce some characters in my
password that are not handled properly by SQL server then.

For example, password ''startreck'' works just fine
password ''test'' does not

Anybody knows how can I fix this problem?

Any help will be greatfully appreciated
Dino

--
-------------------------------------------------------------------------
FIGHT BACK AGAINST SPAM!
Download Spam Inspector, the Award Winning Anti-Spam Filter
http://mail.giantcompany.com


推荐答案

*" D ino M. Buljubasic <二************* @ rivusglobal.com> scripsit:
* "Dino M. Buljubasic" <di*************@rivusglobal.com> scripsit:
我使用MD5来哈希我的密码并将它们作为哈希值添加到数据库中。
我注意到有些密码没有被识别,我想是
这是因为哈希可能会在我的密码中引入一些由SQL服务器无法正确处理的字符。

例如,密码''startreck''工作得很好
密码''测试''没有

有谁知道如何解决这个问题?
I am using MD5 to hash my passwords and add them to database as hashed.
I have noticed though that some passwords don''t get recognized and I suppose
that it happen because hashing might introduce some characters in my
password that are not handled properly by SQL server then.

For example, password ''startreck'' works just fine
password ''test'' does not

Anybody knows how can I fix this problem?




如何计算哈希码?


-

Herfried K. Wagner

MVP·VB Classic,VB.NET

< ; http://www.mvps.org/dotnet>



How do you calculate the hash code?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>


您好Herfried,


感谢您的回复。我正在使用MD5哈希,这里是代码:


公共函数GenerateMD5Hash(ByVal strInput As String)As String


Dim md5Provider As MD5


''为输入字符串生成字节

Dim inputData()As Byte = ASCIIEncoding.ASCII.GetBytes(strInput)

''计算MD5哈希

md5Provider =新MD5CryptoServiceProvider()

Dim hashResult()As Byte = md5Provider.ComputeHash(inputData)


返回ASCIIEncoding.ASCII.GetString(hashResult)


结束函数


因为这个散列可能是介绍性的萎缩,我也是通过用''''替换a b $ b'''(带有双重贬义的萎缩)并且处理得很好。

然而,由于某些原因,某些密码无法找到在我的数据库中

虽然他们在那里,我想这是因为一些无效的角色

besid appostrophy得到介绍但我不确定。


感谢您的帮助,

Dino


-

---- -------------------------------------------------- -------------------

反击垃圾邮件!

下载垃圾邮件督察,屡获殊荣的反垃圾邮件过滤
http://mail.giantcompany.com

" Herfried K. Wagner [MVP]" <喜*************** @ gmx.at>在消息中写道

news:bn ************ @ ID-208219.news.uni-berlin.de ...
Hi Herfried,

thanks for your respond. I am using MD5 hashing, here is the code:

Public Function GenerateMD5Hash(ByVal strInput As String) As String

Dim md5Provider As MD5

'' generate bytes for the input string
Dim inputData() As Byte = ASCIIEncoding.ASCII.GetBytes(strInput)
'' compute MD5 hash
md5Provider = New MD5CryptoServiceProvider()
Dim hashResult() As Byte = md5Provider.ComputeHash(inputData)

Return ASCIIEncoding.ASCII.GetString(hashResult)

End Function

because this hashing may intro apostrophy, I also handle that by replacint a
'' with '''' (apostrophy with double appostrophy) and that gets handled well.
However, from some reason some passwords don''t get found in my database
although they are there and I guess it is because some invalid characters
besid appostrophy get introduced but I am not sure.

Appreciate your help,
Dino

--
-------------------------------------------------------------------------
FIGHT BACK AGAINST SPAM!
Download Spam Inspector, the Award Winning Anti-Spam Filter
http://mail.giantcompany.com
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bn************@ID-208219.news.uni-berlin.de...
* Dino M. Buljubasic <二************* @ rivusglobal.com> scripsit:
* "Dino M. Buljubasic" <di*************@rivusglobal.com> scripsit:
我正在使用MD5来哈希我的密码,并将它们作为哈希值添加到数据库中。
我注意到有些密码没有被识别,我猜b $ b假设这是因为哈希可能会在我的密码中引入一些由SQL服务器无法正确处理的字符。

例如,密码''startreck''工作得很好
密码''测试''没有

有谁知道如何解决这个问题?
I am using MD5 to hash my passwords and add them to database as hashed.
I have noticed though that some passwords don''t get recognized and I suppose that it happen because hashing might introduce some characters in my
password that are not handled properly by SQL server then.

For example, password ''startreck'' works just fine
password ''test'' does not

Anybody knows how can I fix this problem?



如何计算哈希码?

-
Herfried K. Wagner
MVP·VB Classic,VB.NET
< http://www.mvps.org/dotnet>



How do you calculate the hash code?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>



2003年10月22日星期三19:29:51 GMT,Dino M. Buljubasic

< di ******* ******@rivusglobal.com>写道:
On Wed, 22 Oct 2003 19:29:51 GMT, "Dino M. Buljubasic"
<di*************@rivusglobal.com> wrote:
嗨Herfried,

感谢您的回复。我正在使用MD5哈希,这里是代码:

公共函数GenerateMD5Hash(ByVal strInput As String)As String

Dim md5Provider As MD5

''为输入字符串生成字节
Dim inputData()As Byte = ASCIIEncoding.ASCII.GetBytes(strInput)

''计算MD5哈希
md5Provider =新MD5CryptoServiceProvider()
Dim hashResult()As Byte = md5Provider.ComputeHash(inputData)

返回ASCIIEncoding.ASCII.GetString(hashResult)

结束函数

因为这个散列可能是介绍性的萎缩,我也可以通过替换来处理这个问题,然后用'''''(带有双重痉挛的萎缩)并且处理得很好。
但是,由于某些原因,有些密码不能在我的数据库中找到
虽然它们在那里,我想这是因为一些无效的角色
besid appostrophy得到介绍但我不确定。

赞赏哟你的帮助,
Dino
Hi Herfried,

thanks for your respond. I am using MD5 hashing, here is the code:

Public Function GenerateMD5Hash(ByVal strInput As String) As String

Dim md5Provider As MD5

'' generate bytes for the input string
Dim inputData() As Byte = ASCIIEncoding.ASCII.GetBytes(strInput)
'' compute MD5 hash
md5Provider = New MD5CryptoServiceProvider()
Dim hashResult() As Byte = md5Provider.ComputeHash(inputData)

Return ASCIIEncoding.ASCII.GetString(hashResult)

End Function

because this hashing may intro apostrophy, I also handle that by replacint a
'' with '''' (apostrophy with double appostrophy) and that gets handled well.
However, from some reason some passwords don''t get found in my database
although they are there and I guess it is because some invalid characters
besid appostrophy get introduced but I am not sure.

Appreciate your help,
Dino




前一段时间我遇到过类似的问题 - 结果原因是

字符编码在数据库。我的解决方案(以及我对所有数据库和模型应用

的解决方案)是生成一个ASCII友好的(实际上是,
7位)哈希的版本。基本上,我只使用每个字节

的十六进制数字。

并且在生成
$ b $时记得将用户ID与密码混合使用b hash(我想这不用说了,但我已经看过它了一百元

次!)


Rgds,




I had similar problems a while ago - the cause turned out to be
character encoding in the database. My solution (and one which I apply
to all databases & models) is to produce an ASCII-friendly (actually,
7-bit) verion of the hash. Basically, I just use the hex digits of
each of the bytes.
And remember to mix the user ID with the password when generating the
hash (I suppose it goes without saying, but I''ve seen it a hundred
times!)

Rgds,



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

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