Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CHECKSUM and CHECKSUM_AGG: What's the algorithm?

We perform checksums of some data in sql server as follows:

declare @cs int;
select 
    @cs = CHECKSUM_AGG(CHECKSUM(someid, position))
from 
    SomeTable
where 
    userid = @userId
group by 
    userid;

This data is then shared with clients. We'd like to be able to repeat the checksum at the client end... however there doesn't seem to be any info about how the checksums in the functions above are calculated. Can anyone enlighten me?

like image 729
spender Avatar asked May 01 '13 09:05

spender


People also ask

What is a checksum algorithm?

The checksum algorithm is really a special kind of hash function. A hash function is a function, or process, that can be used to map data of arbitrary size to data of a fixed size. The types of hashes used for data integrity are distinguished by the presence or absence of keys and cryptographic properties.

What is the best checksum algorithm?

The SHA family of algorithms is published by the National Institute of Standards and Technology. One algorithm, SHA-1, produces a 160-bit checksum and is the best-performing checksum, followed by the 256-bit and 512-bit versions.

How is checksum calculated in SQL?

CHECKSUM computes a hash value, called the checksum, over its argument list. Use this hash value to build hash indexes. A hash index will result if the CHECKSUM function has column arguments, and an index is built over the computed CHECKSUM value. This can be used for equality searches over the columns.

What is checksum in hashing?

A cryptographic hash, or checksum, is a digital fingerprint of a piece of data (e.g., a block of text) which can be used to check that you have an unaltered copy of that data. Emacs supports several common cryptographic hash algorithms: MD5, SHA-1, SHA-2, SHA-224, SHA-256, SHA-384 and SHA-512.


1 Answers

On SQL Server Forum, at this page, it's stated:

The built-in CHECKSUM function in SQL Server is built on a series of 4 bit left rotational xor operations. See this post for more explanation.

like image 138
Dan Avatar answered Sep 20 '22 02:09

Dan