SQL-запрос
Код: Выделить всё
Select hashbytes('MD5', PNumber+CONVERT(VARCHAR(50),cast(datestamp as binary),1))
From dbo.Events
Я использую приведенный ниже код, чтобы получить эквивалент C#. Но значения не совпадают
Код C#
Код: Выделить всё
var strDate = policyEventFromQueue.DateStamp.ToString();
var binaryvalue = Encoding.Unicode.GetBytes(strDate);
var hashkey = GetMD5Hash(PNumber + binaryvalue);
public static byte[] GetMD5Hash(string input)
{
System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] bs = System.Text.Encoding.Unicode.GetBytes(input);
bs = x.ComputeHash(bs);
return bs;
}
Из SQL Server:
Код: Выделить всё
PNumber ='4272535529'
DateStamp ='2016-06-30 12:19:35.257961'
HashValue : 0x104E09499B76CB59420AEEEDBBE187F8
Код: Выделить всё
[0]: 16
[1]: 78
[2]: 9
[3]: 73
[4]: 155
[5]: 118
[6]: 203
[7]: 89
[8]: 66
[9]: 10
[10]: 238
[11]: 237
[12]: 187
[13]: 225
[14]: 135
[15]: 248
Код: Выделить всё
[0]: 30
[1]: 153
[2]: 105
[3]: 203
[4]: 34
[5]: 124
[6]: 20
[7]: 12
[8]: 207
[9]: 113
[10]: 210
[11]: 144
[12]: 18
[13]: 145
[14]: 22
[15]: 36
Подробнее здесь: https://stackoverflow.com/questions/387 ... s-function
Мобильная версия