English 中文(简体)
在LQ中使用HashBytes 服务器收益与非行不同
原标题:Using HashBytes in SQL Server returns different results from DB

我试图以某种价值计算出五分之二,但我却取得了令人ir慕的结果。

我以两种不同方式处理:

SELECT HASHBYTES( md5 ,ZLA_PASSWORD),ZLA_PASSWORD, len(ZLA_PASSWORD) FROM ZLA_PASSWORD;

SELECT HASHBYTES( md5 ,  123456 );

我获得两种不同的结果,只有第二种结果有效:

0xCE0BFD15059B68D67688884D7A3D3E8C  123456  6
0xE10ADC3949BA59ABBE56E057F20F883E

这是在2005年的一个服务器上进行的。

检查123456年MD5的结果与在线第二次结果核对相同。

任何想法?

感谢!

问题回答

您的数据类型各不相同。

declare @str1 as varchar(10)
declare @str2 as nvarchar(10)

set @str1 =  123456 
set @str2 =  123456 

select
  hashbytes( md5 , @str1) as  varchar ,
  hashbytes( md5 , @str2) as  nvarchar 

成果

varchar                             nvarchar
0xE10ADC3949BA59ABBE56E057F20F883E  0xCE0BFD15059B68D67688884D7A3D3E8C

LEN 在归还长度之前,将内容提一下(三轮str)。

您的密码领域很可能是菲律宾人权委员会的一个领域,是那里的一个白天空间。

提一下:

SELECT HASHBYTES( md5 ,RTRIM(ZLA_PASSWORD))

更确切地说,这应当解决这个问题:

SELECT HASHBYTES( md5 ,CAST(ZLA_PASSWORD AS varchar)),ZLA_PASSWORD, len(ZLA_PASSWORD) FROM ZLA_PASSWORD;




相关问题
what is wrong with this mysql code

$db_user="root"; $db_host="localhost"; $db_password="root"; $db_name = "fayer"; $conn = mysqli_connect($db_host,$db_user,$db_password,$db_name) or die ("couldn t connect to server"); // perform query ...

Users asking for denormalized database

I am in the early stages of developing a database-driven system and the largest part of the system revolves around an inheritance type of relationship. There is a parent entity with about 10 columns ...

Easiest way to deal with sample data in Java web apps?

I m writing a Java web app in my free time to learn more about development. I m using the Stripes framework and eventually intend to use hibernate and MySQL For the moment, whilst creating the pages ...

join across databases with nhibernate

I am trying to join two tables that reside in two different databases. Every time, I try to join I get the following error: An association from the table xxx refers to an unmapped class. If the ...

How can I know if such value exists in database? (ADO.NET)

For example, I have a table, and there is a column named Tags . I want to know if value programming exists in this column. How can I do this in ADO.NET? I did this: OleDbCommand cmd = new ...

Convert date to string upon saving a doctrine record

I m trying to migrate one of my PHP projects to Doctrine. I ve never used it before so there are a few things I don t understand. In my current code, I have a class similar to this: class ...

热门标签