August 9, 2018 at 6:52 am
Hello All,
For educational purposes I am seeking for a HASH algoritmn to be shown and used in SSMS.
During an introduction of SSMS/SQL I would like to use a HASH algoritm and show what is does. The SHA 256 algoritm would be nice because it's general use for usefull and less usefull purposes over all the world.
I would like a simple equivalent of the SHA 256 algoritm, to show that and how it actually works. And the full SHA 256 algoritm to show that this is a 'generic' algoritm that if we want we could implement in SSMS.
To be able to show the concept, a simple algoritm and then the full blown SHA 256 algoritm would be powerfull during the course. Showing the SHA 256 algoritm outside the SSMS (or in CLR technologie) would defeat the purpose.
No 'practical' implementation is needed, because this is pure educational.
Except dat it can be demonstrated there are no performance requirements.
Thanks for your time and attention.
Ben
August 9, 2018 at 9:20 am
If you are looking for the algorithm, not sure I can help. You are aware that hashbytes function in SQL Server implements SHA algorithms, you just can't see the code.
August 10, 2018 at 1:03 am
Well a simple algorithm is easy:Select sometext, left(sometext, 5) as hash from #table
Now it's a naïve hash with a fairly high probability of collisions, but it's still technically a hash. Better hashing algorithms are all about reducing the probability of collisions because that makes them more useful in a practical sense.
August 10, 2018 at 1:56 am
ben.brugman - Thursday, August 9, 2018 6:52 AMHello All,For educational purposes I am seeking for a HASH algoritmn to be shown and used in SSMS.
During an introduction of SSMS/SQL I would like to use a HASH algoritm and show what is does. The SHA 256 algoritm would be nice because it's general use for usefull and less usefull purposes over all the world.
I would like a simple equivalent of the SHA 256 algoritm, to show that and how it actually works. And the full SHA 256 algoritm to show that this is a 'generic' algoritm that if we want we could implement in SSMS.
To be able to show the concept, a simple algoritm and then the full blown SHA 256 algoritm would be powerfull during the course. Showing the SHA 256 algoritm outside the SSMS (or in CLR technologie) would defeat the purpose.
No 'practical' implementation is needed, because this is pure educational.
Except dat it can be demonstrated there are no performance requirements.Thanks for your time and attention.
Ben
Here is a link to the SHA-256 in JavaScript, not a trivial task to implement it in T-SQL 😉
😎
You can of course use the HASHBYTE function to check the output.SELECT
HASHBYTES(N'SHA2_256',N'THIS IS MY HELLO WORLD HASH') AS SHA2_256
;
September 4, 2018 at 12:48 am
I did play around with the suggested functions.
Thanks for all your replies, they were usefull to me.
Ben
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply