Author |
Topic |
SamC
White Water Yakist
3467 Posts |
Posted - 2006-02-07 : 10:21:56
|
Anyone know of an open-source SQL stored proc that'll do SHA-1 hash? |
|
spirit1
Cybernetic Yak Master
11752 Posts |
|
Kristen
Test
22859 Posts |
|
Frank Kalis
Constraint Violating Yak Guru
413 Posts |
|
SamC
White Water Yakist
3467 Posts |
Posted - 2006-02-07 : 11:00:13
|
quote: Originally posted by Kristen This is where I normal kick off for Encryption stuff:http://pajhome.org.uk/crypt/md5/There's a link on there for a SQL solution to http://wonko.com/xpcrypt/ - which is dead but it pops up again on http://www.15seconds.com/component/pg000272.htm
The xp_crypt is now at http://www.activecrypt.com/products.htmlbut I didn't want to install a dll. Seems like a T-SQL SP wouldn't be *too* hard to write based on PAJ's (http://pajhome.org.uk/crypt/md5/sha1src.html) JavaScript implementation of SHA-1. The trick would be to translate the looping structures into set-based SQL for efficent execution.Any takers? |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2006-02-07 : 11:07:02
|
quote: Originally posted by Frank Kalis FWIW, here's an extended stored procedure implementing MD5: http://www.codeproject.com/database/xp_md5.asp
Another (very good) C++ implementation. There is probably a very good reason why these hash functions are not written in T-SQL. |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-02-07 : 11:43:48
|
quote: Originally posted by SamC
quote: Originally posted by Kristen This is where I normal kick off for Encryption stuff:http://pajhome.org.uk/crypt/md5/There's a link on there for a SQL solution to http://wonko.com/xpcrypt/ - which is dead but it pops up again on http://www.15seconds.com/component/pg000272.htm
The xp_crypt is now at http://www.activecrypt.com/products.htmlbut I didn't want to install a dll. Seems like a T-SQL SP wouldn't be *too* hard to write based on PAJ's (http://pajhome.org.uk/crypt/md5/sha1src.html) JavaScript implementation of SHA-1. The trick would be to translate the looping structures into set-based SQL for efficent execution.Any takers?
We have been using xp_crypt for several years with no problem.You do have to pay for it, but it provides a number of hash and encryption stored procedures.There is also a free version that does MD5, DES, SHA1, SHA-256, and SHA-512 hashes.CODO ERGO SUM |
|
|
X002548
Not Just a Number
15586 Posts |
|
Kristen
Test
22859 Posts |
Posted - 2006-02-08 : 03:14:21
|
"eProblem"They're the only type of problems I get these days Kristen |
|
|
Arnold Fribble
Yak-finder General
1961 Posts |
Posted - 2006-02-08 : 03:55:48
|
It's probably worth pointing out that, in strict cryptographical terms, both MD5 and SHA-1 have been shown to be broken:http://en.wikipedia.org/wiki/SHA-1#Cryptanalysis_of_SHA-1http://en.wikipedia.org/wiki/Xiaoyun_Wang |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2006-02-08 : 09:35:06
|
quote: Originally posted by Arnold Fribble It's probably worth pointing out that, in strict cryptographical terms, both MD5 and SHA-1 have been shown to be broken:http://en.wikipedia.org/wiki/SHA-1#Cryptanalysis_of_SHA-1http://en.wikipedia.org/wiki/Xiaoyun_Wang
Arnold - I like the follow up but... quote: In early 2005, Rijmen and Oswald published an attack on a reduced version of SHA-1 — 53 out of 80 rounds — which finds collisions with a complexity of fewer than 2**80 operations
2**80 is a large number...I am still intreagued by the idea of a T-SQL implementation of SHA-1. NIST's paper on SHA-N algorithms isn't rocket science. While easy to implement in non-set based languages, there are several items in the loops which a set-based language could take advantage of: Initialization of W(i) for example.Of most concern is the lack of boolean operators in SQL (I should say boolean operators which transform data.), e.g. XOR or ROTL (rotate left) which could be implemented with integer arithmetic, but begins to dampen spirit, not to mention the performance |
|
|
Frank Kalis
Constraint Violating Yak Guru
413 Posts |
|
SamC
White Water Yakist
3467 Posts |
Posted - 2006-02-08 : 11:06:59
|
quote: Originally posted by Frank Kalis You might want to check out these threads:http://snipurl.com/mccqhttp://snipurl.com/mcco
Learn something new all the time...bitwise SQL operators: quote: & (Bitwise AND) Bitwise AND (two operands). | (Bitwise OR) Bitwise OR (two operands). ^ (Bitwise Exclusive OR) Bitwise exclusive OR (two operands).
And... a nice SHA-1 T-SQL function by Steve Kass, suitable for password encryption (strings of 55 bytes or less). Could be written using set operations? |
|
|
Frank Kalis
Constraint Violating Yak Guru
413 Posts |
|
SamC
White Water Yakist
3467 Posts |
Posted - 2006-02-09 : 07:55:46
|
quote: Originally posted by Frank Kalis Try it out! Once you're done, I would love to have a copy.
I get stumped with a vector initialized with 16 values, the remaining 64 values are calculated: W(i) = f(W(i-16))Values of W 17 .. 79 are undefined and an INSERT statement takes the values "as they are" as opposed to "as they are calculated". Calculating W(79) references W(79-16), a value which is undefined. It'll take a loop, not an INSERT to calculate all the values. Unless there's a trick to get around this problem. |
|
|
X002548
Not Just a Number
15586 Posts |
|
|