• Michael Meierruth (10/7/2013)


    Then I tried:

    select dbo.sha256Hash(o1.name)

    from sys.all_objects o1,sys.all_objects o2

    which took 46 seconds and extracted 4 million rows, followed by

    select dbo.sha256Hash(dbo.sha256Hash(o1.name))

    from sys.all_objects o1,sys.all_objects o2

    which took 93 seconds, as expected.

    Will anyone beat this writing the function in SQL? :w00t:

    There's a few things to note here. First, we typically wouldn't hash millions of rows regularly. You'd use this in spots for a few values, so some of the inefficiencies here are fine.

    Second, you can't implemen SHA-3 (or strong SHA-2 algorithms pre SQL2K12) any other way. SHA-11 has been attacked, so I'd recommend this moving forward for that data that you want to protect and use in a hashing situation.