Friday, March 23, 2012

Need example of a "Hash" function.....

Many articles on sql server security make reference to Hash functions. Do you know of a simple example of a hash function that I could show to others?

For example, would taking the first eight bytes of the mathematical "sin" of a number be a good function? I don't know. Or is a hash "function" actually an involved algorithm, so the "simple" formula I was looking for really doesn't exist.

TIA,

Barkingdog

In SQL Server 2005 we have a new builtin to calculate hash functions: HashBytes.

For more details on this builtin I recommend consulting BOL (http://msdn2.microsoft.com/en-us/library/ms174415.aspx), but here is a short example:

SELECT HashBytes( 'sha1', '1234' )

-- returns 0x7110EDA4D09E062AA5E4A390B0A572AC0D2C0220

SELECT HashBytes( 'md5', '1234' )

--returns 0x81DC9BDB52D04DC20036DBD8313ED055

-Raul Garcia

SDE/T

SQL Server Engine

|||

I have read that both MD5 and SHA1 (its successor) have been "compromised". Is this true?

Barkingdog

No comments:

Post a Comment