Happy New Year 2016

  • Comments posted to this topic are about the item Happy New Year 2016

  • Nice easy question to start the year, thanks Steve.

    ...

  • After all, just something new today for me, thank you Steve. Happy New year to you all.:-)

  • Nice question. The longest hash had to be correct, so it was rather easy (counting the characters to check there were actually 64 was the only hard part).

    But did you hash the string as varchar or as nvarchar? They produce different answers of course. It might have been fun to list both sets of hashes and ask people to choose 2, just to make people think a little harder.

    Tom

  • Good new information 2 start the year with, thanx 4 the 7 points, Happy New Year everyone.

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

  • Happy New Year to everyone. My holiday time off is over, so back to work.

  • Nice question, thanks.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Don't know how many bytes it was but it was the longest.

  • TomThomson (1/1/2016)


    Nice question. The longest hash had to be correct, so it was rather easy (counting the characters to check there were actually 64 was the only hard part).

    But did you hash the string as varchar or as nvarchar? They produce different answers of course. It might have been fun to list both sets of hashes and ask people to choose 2, just to make people think a little harder.

    varchar, though I thought about nvarchar. Thought that might not be fair.

  • Steve, I'd like to see your code because I can't duplicate it. I ran the following:

    DECLARE @HashThis VARCHAR(20) = 'January 1, 2016';

    SELECT 'MD2' AS HashType, hashbytes('MD2',@HashThis) AS HashVal

    UNION

    SELECT 'MD4', hashbytes('MD4',@HashThis)

    UNION

    SELECT 'MD5', hashbytes('MD5',@HashThis)

    UNION

    SELECT 'SHA', hashbytes('SHA',@HashThis)

    UNION

    SELECT 'SHA1', hashbytes('SHA1',@HashThis)

    UNION

    SELECT 'SHA2-256', hashbytes('SHA2-256',@HashThis)

    UNION

    SELECT 'SHA2-512', hashbytes('SHA2-512',@HashThis);

    And got this as text output:

    HashType HashVal

    -------- ------------------------------------------------------------------------ ...

    MD2 0x597769E83A509A788FC891AD451B102B

    MD4 0x760C51EFC11D5B932BDCA99ED0B889CD

    MD5 0xF1A4456FAF93F6FD842344D0AC06D7A1

    SHA 0xD186F5A70C77B99E0FB644C86066E267218A1BC8

    SHA1 0xD186F5A70C77B99E0FB644C86066E267218A1BC8

    SHA2-256 NULL

    SHA2-512 NULL

    (7 row(s) affected)

    I find it odd that I'm getting nulls for the SHA2 hashbytes. This is on SQL Server 2014 Developer Edition with SP1 (12.0.4100.1). Makes me wonder if something is funky about my installation and I just haven't noticed it yet.

    -----
    [font="Arial"]Knowledge is of two kinds. We know a subject ourselves or we know where we can find information upon it. --Samuel Johnson[/font]

  • Wayne West (1/4/2016)


    Steve, I'd like to see your code because I can't duplicate it. I ran the following:

    DECLARE @HashThis VARCHAR(20) = 'January 1, 2016';

    SELECT 'MD2' AS HashType, hashbytes('MD2',@HashThis) AS HashVal

    UNION

    SELECT 'MD4', hashbytes('MD4',@HashThis)

    UNION

    SELECT 'MD5', hashbytes('MD5',@HashThis)

    UNION

    SELECT 'SHA', hashbytes('SHA',@HashThis)

    UNION

    SELECT 'SHA1', hashbytes('SHA1',@HashThis)

    UNION

    SELECT 'SHA2-256', hashbytes('SHA2-256',@HashThis)

    UNION

    SELECT 'SHA2-512', hashbytes('SHA2-512',@HashThis);

    And got this as text output:

    HashType HashVal

    -------- ------------------------------------------------------------------------ ...

    MD2 0x597769E83A509A788FC891AD451B102B

    MD4 0x760C51EFC11D5B932BDCA99ED0B889CD

    MD5 0xF1A4456FAF93F6FD842344D0AC06D7A1

    SHA 0xD186F5A70C77B99E0FB644C86066E267218A1BC8

    SHA1 0xD186F5A70C77B99E0FB644C86066E267218A1BC8

    SHA2-256 NULL

    SHA2-512 NULL

    (7 row(s) affected)

    I find it odd that I'm getting nulls for the SHA2 hashbytes. This is on SQL Server 2014 Developer Edition with SP1 (12.0.4100.1). Makes me wonder if something is funky about my installation and I just haven't noticed it yet.

    DECLARE @HashThis VARCHAR(20) = 'January 1, 2016';

    SELECT 'MD2' AS HashType, hashbytes('MD2',@HashThis) AS HashVal

    UNION

    SELECT 'MD4', hashbytes('MD4',@HashThis)

    UNION

    SELECT 'MD5', hashbytes('MD5',@HashThis)

    UNION

    SELECT 'SHA', hashbytes('SHA',@HashThis)

    UNION

    SELECT 'SHA1', hashbytes('SHA1',@HashThis)

    UNION

    SELECT 'SHA2_256 NOTE UNDERSCORE', hashbytes('SHA2_256',@HashThis)

    UNION

    SELECT 'SHA2_512 NOTE UNDERSCORE', hashbytes('SHA2_512',@HashThis);

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • J Livingston caught it.

    Underscores in the algorithm

  • Thank you, J! Yep, PEBKAC strikes again.

    -----
    [font="Arial"]Knowledge is of two kinds. We know a subject ourselves or we know where we can find information upon it. --Samuel Johnson[/font]

  • Wayne West (1/4/2016)


    Steve, I'd like to see your code because I can't duplicate it. I ran the following:

    DECLARE @HashThis VARCHAR(20) = 'January 1, 2016';

    SELECT 'MD2' AS HashType, hashbytes('MD2',@HashThis) AS HashVal

    UNION

    SELECT 'MD4', hashbytes('MD4',@HashThis)

    UNION

    SELECT 'MD5', hashbytes('MD5',@HashThis)

    UNION

    SELECT 'SHA', hashbytes('SHA',@HashThis)

    UNION

    SELECT 'SHA1', hashbytes('SHA1',@HashThis)

    UNION

    SELECT 'SHA2-256', hashbytes('SHA2-256',@HashThis)

    UNION

    SELECT 'SHA2-512', hashbytes('SHA2-512',@HashThis);

    And got this as text output:

    HashType HashVal

    -------- ------------------------------------------------------------------------ ...

    MD2 0x597769E83A509A788FC891AD451B102B

    MD4 0x760C51EFC11D5B932BDCA99ED0B889CD

    MD5 0xF1A4456FAF93F6FD842344D0AC06D7A1

    SHA 0xD186F5A70C77B99E0FB644C86066E267218A1BC8

    SHA1 0xD186F5A70C77B99E0FB644C86066E267218A1BC8

    SHA2-256 NULL

    SHA2-512 NULL

    (7 row(s) affected)

    I find it odd that I'm getting nulls for the SHA2 hashbytes. This is on SQL Server 2014 Developer Edition with SP1 (12.0.4100.1). Makes me wonder if something is funky about my installation and I just haven't noticed it yet.

    +1 different results with my SQL Server 2014 RTM Express

    declare @val varchar(512)

    set @val = convert(varchar(512),'January 1, 2016')

    select HASHBYTES('SHA2_256',@val)

    select HASHBYTES('SHA2_512',@val)

    I am getting :

    0x3B26AECCDA7B29EEE926C93A32EB0EEBA212896EF85F63EBE2206C04175C956F

    and

    0x717F004400D0AF13E5ABCEAB7508D5A3FE346671FFA114696B42E22A9158EE1B41BD016F21155437E29E708186DECB603B03A9C509146CECD1B84D4F2647E484

    I think I have done some errors in my code ( logical it is 2016-01-05 00:54... or I am tired )

    Have a nice day

    Horror .. I have forgotten : happy new year

  • J Livingston SQL (1/4/2016)


    Wayne West (1/4/2016)


    Steve, I'd like to see your code because I can't duplicate it. I ran the following:

    DECLARE @HashThis VARCHAR(20) = 'January 1, 2016';

    SELECT 'MD2' AS HashType, hashbytes('MD2',@HashThis) AS HashVal

    UNION

    SELECT 'MD4', hashbytes('MD4',@HashThis)

    UNION

    SELECT 'MD5', hashbytes('MD5',@HashThis)

    UNION

    SELECT 'SHA', hashbytes('SHA',@HashThis)

    UNION

    SELECT 'SHA1', hashbytes('SHA1',@HashThis)

    UNION

    SELECT 'SHA2-256', hashbytes('SHA2-256',@HashThis)

    UNION

    SELECT 'SHA2-512', hashbytes('SHA2-512',@HashThis);

    And got this as text output:

    HashType HashVal

    -------- ------------------------------------------------------------------------ ...

    MD2 0x597769E83A509A788FC891AD451B102B

    MD4 0x760C51EFC11D5B932BDCA99ED0B889CD

    MD5 0xF1A4456FAF93F6FD842344D0AC06D7A1

    SHA 0xD186F5A70C77B99E0FB644C86066E267218A1BC8

    SHA1 0xD186F5A70C77B99E0FB644C86066E267218A1BC8

    SHA2-256 NULL

    SHA2-512 NULL

    (7 row(s) affected)

    I find it odd that I'm getting nulls for the SHA2 hashbytes. This is on SQL Server 2014 Developer Edition with SP1 (12.0.4100.1). Makes me wonder if something is funky about my installation and I just haven't noticed it yet.

    DECLARE @HashThis VARCHAR(20) = 'January 1, 2016';

    SELECT 'MD2' AS HashType, hashbytes('MD2',@HashThis) AS HashVal

    UNION

    SELECT 'MD4', hashbytes('MD4',@HashThis)

    UNION

    SELECT 'MD5', hashbytes('MD5',@HashThis)

    UNION

    SELECT 'SHA', hashbytes('SHA',@HashThis)

    UNION

    SELECT 'SHA1', hashbytes('SHA1',@HashThis)

    UNION

    SELECT 'SHA2_256 NOTE UNDERSCORE', hashbytes('SHA2_256',@HashThis)

    UNION

    SELECT 'SHA2_512 NOTE UNDERSCORE', hashbytes('SHA2_512',@HashThis);

    Thanks for this.

    Happy New Year!

    Igor Micev,My blog: www.igormicev.com

Viewing 15 posts - 1 through 15 (of 15 total)

You must be logged in to reply to this topic. Login to reply