// एसक्यूएल और सी # दर्पण यूक्रेन // HASH_ZKCRC64 के त्वरित हैश योग /// ----------------------- -------------------------------------------------- ------------------------------------- निजी इंट 64 HASH_ZKCRC64 (बाइट [] डेटा) { Int64 परिणाम = 0x5555555555555555; यदि (डेटा == शून्य] डेटा। लम्बाई < = 0) 0 लौटाएं; int SizeGlobalBufer = 8000; int Ost = डेटा। लम्बाई% SizeGlobalBufer; int LeftLimit = (डेटा। लम्बाई/आकारग्लोबलबफर) * SizeGlobalBufer;
for (int i = 0; i < LeftLimit; i += 64)
{
Result = Result
^BitConverter.ToInt64(Data, i)
^BitConverter.ToInt64(Data, i + 8)
^BitConverter.ToInt64(Data, i + 16)
^BitConverter.ToInt64(Data, i + 24)
^BitConverter.ToInt64(Data, i + 32)
^BitConverter.ToInt64(Data, i + 40)
^BitConverter.ToInt64(Data, i + 48)
^BitConverter.ToInt64(Data, i + 56);
if ((Result & 0x0000000000000080) != 0)
Result = Result^BitConverter.ToInt64(Data, i + 28);
}
if (Ost > 0)
{
byte[] Bufer = new byte[SizeGlobalBufer];
Array.Copy(Data, LeftLimit, Bufer, 0, Ost);
for (int i = 0; i < SizeGlobalBufer; i += 64)
{
Result = Result
^BitConverter.ToInt64(Bufer, i)
^BitConverter.ToInt64(Bufer, i + 8)
^BitConverter.ToInt64(Bufer, i + 16)
^BitConverter.ToInt64(Bufer, i + 24)
^BitConverter.ToInt64(Bufer, i + 32)
^BitConverter.ToInt64(Bufer, i + 40)
^BitConverter.ToInt64(Bufer, i + 48)
^BitConverter.ToInt64(Bufer, i + 56);
if ((Result & 0x0000000000000080)!=0)
Result = Result^BitConverter.ToInt64(Bufer, i + 28);
}
}
byte[] MiniBufer = BitConverter.GetBytes(Result);
Array.Reverse(MiniBufer);
return BitConverter.ToInt64(MiniBufer, 0);
#region SQL_FUNCTION
/* CREATE FUNCTION [dbo].[HASH_ZKCRC64] (@data as varbinary(MAX)) Returns bigint
AS
BEGIN
Declare @I64 as bigint Set @I64=0x5555555555555555
Declare @Bufer as binary(8000)
Declare @i as int Set @i=1
Declare @j as int
Declare @Len as int Set @Len=Len(@data)
if ((@data is null) Or (@Len<=0)) Return 0
While @i<[email protected]
Begin
Set @Bufer=Substring(@data,@i,8000)
Set @j=1
While @j<=8000
Begin
Set @[email protected]
^CAST(Substring(@Bufer,@j, 8) as bigint)
^CAST(Substring(@Bufer,@j+8, 8) as bigint)
^CAST(Substring(@Bufer,@j+16,8) as bigint)
^CAST(Substring(@Bufer,@j+24,8) as bigint)
^CAST(Substring(@Bufer,@j+32,8) as bigint)
^CAST(Substring(@Bufer,@j+40,8) as bigint)
^CAST(Substring(@Bufer,@j+48,8) as bigint)
^CAST(Substring(@Bufer,@j+56,8) as bigint)
if @I64<0 Set @[email protected]^CAST(Substring(@Bufer,@j+28,8) as bigint)
Set @[email protected]+64
End;
Set @[email protected]+8000
End
Return @I64
END
*/
#endregion
}
धन्यवाद! मुझे इसे डेटाटाइप के विशेष मामले में थोड़ा सा ट्विक करना पड़ा, लेकिन मैं इस समाधान के आधार पर तेजी से और कुछ ऐसा करने में सक्षम था। अति उत्कृष्ट! –
बस पहचान कॉलम से सावधान रहें, मैं भी BINARY_CHECKSUM का उपयोग करूंगा क्योंकि यह मामला संवेदनशील है। –