from Hacker News

Break my stupid hash function

by quackduck on 8/7/22, 1:58 AM with 3 comments

I made this crappy, most likely very insecure hash function with zero actual cryptographic hash knowledge while on a plane.

If you can find a collision or find the preimage of f11e7def9c2ec4c0, you'll officially have broken it.

Link: https://gist.github.com/quackduck/0da5d2ed7807e3ef22dc2e0cdadbf90a

  • by gus_massa on 8/7/22, 3:55 AM

    With

        300000002a00000041e00000
    
    I get

        e078387cb36ec4c0
    
    your hash is

        f11e7def9c2ec4c0
    
    so I reversed 5 chars.

    In line 39 it says "num*num" where num is the value of each 8 character block, so if I make each block a multiple of a power of 16, it will not modify the last character of the output. So I can discover each character one by one. I should be padding with \null instead of 0, but it somewhat works anyway.

    Also, you use 0x428a2f98 as a magic constant, but you should use an odd numbers instead of an even one. If not, you lose the last bits. If you take a look at the output of your hash, the last character is always 0 or 8.

  • by developedbytoby on 8/7/22, 2:07 AM

    incredible.