News for hackers. Stuff that matters.
Re:The SHA256 for this sentence begins with: one, eight, two... by rawling on Monday September 11, 2023 @06:17AM (#37465145)
> Was just verifying your tweet's hash, and then...omg!!! I couldn't believe what I realised. The SHA256 of THIS tweet starts with exactly the same 7 characters as your tweet's hash. What are the chances of that?

As always, the real WTF is in the comments.

Re:The SHA256 for this sentence begins with: one, eight, two... by isp on Monday September 11, 2023 @06:26AM (#37465213)

    $ echo -n $'Was just verifying your tweet\'s hash, and then...omg!!! I couldn\'t believe what I realised. The SHA256 of THIS tweet starts with exactly the same 7 characters as your tweet\'s hash. What are the chances of that?' | sha256sum
    182a7c9c08b2f0f9333bf23828c5fbf47addf74e815b6a22ca10825450bc2ee1  -
Checks out(!)

Source: https://twitter.com/benoconnor/status/1701057433131421935

Re:The SHA256 for this sentence begins with: one, eight, two... by rawling on Monday September 11, 2023 @06:33AM (#37465268)
I'm confused as to how they've done this. The original message, sure, you can brute force the digits and hope you get a collision, and try a new, plausible preamble if not. But I don't see how they've found this collision without it looking like anything is brute forced.

Is it using substitute Unicode characters or something?

E: no, just hand typed it and got the same...

Re:The SHA256 for this sentence begins with: one, eight, two... by noctune on Monday September 11, 2023 @11:02AM (#37468299)
7 digits of the hash makes for 16*7 possible hashes. I spot 4 potential "filler" lines in that tweet, so if you find log4(16*7)=14 candidates for each of those filler lines, then one combination would be expected to yield that hash.
Re:The SHA256 for this sentence begins with: one, eight, two... by kazinator on Monday September 11, 2023 @11:03AM (#37468337)
You can generate sentences of the form "This sentence begins with: " followed by seven comma-separated english words denoting hex digits. Then search that space of digits, until you get a hit.

For each digit combination, you can try it with multiple variations of the sentence like "The SHA256 of this sentence begins with", "The SHA256 hash of this text starts with" and many more. That increases the search space without increasing the number of digits that have to match, making it more likely that a hit is found.

Re:The SHA256 for this sentence begins with: one, eight, two... by fbdab103 on Monday September 11, 2023 @11:24AM (#37468672)
Iterating on the prefix sentence construction seems significantly more challenging that just looping through n digits with a counter.

"The SHA256 for this sentence begins with" : 0, 0, 0, 0, 0?

"The SHA256 for this sentence begins with" : 0, 0, 0, 0, 1?

"The SHA256 for this sentence begins with" : 0, 0, 0, 0, 2?

Make the n list as big of a search space as you are willing to compute, and there you go. Of course, given my luck, the hash would be f,f,f,f,f.

Re:The SHA256 for this sentence begins with: one, eight, two... by devit on Monday September 11, 2023 @11:48AM (#37469044)
Presumably generated lots of variations of that sentence. It's 28 bits, so you only need to have around 14 places where 4 variations are possible.

For instance, it could start with "Was", "I was", "verifying" could be "checking" or "computing" or "testing", etc.

A bit tight, but it seems feasible with some work.

Re:The SHA256 for this sentence begins with: one, eight, two... by fbdab103 on Monday September 11, 2023 @12:14PM (#37469441)
Throwing a loop of numbers on the end seems far more feasible. I put together a hasty Python implementation which can immediately find three hits at 5 characters. TQDM is reporting ~450k tries per second, so depending on how lucky you are, would probably want to redo in a faster language to solve for 7+

    import hashlib
    import itertools
    
    import tqdm
    
    BLOCKS_SIZE = 5
    sentence_prefix = "The SHA256 for this sentence begins with:"
    
    itos = {0x00:"zero", 0x01:"one", 0x02:"two", 0x03:"three", 0x04:"four", 0x05:"five", 0x06:"six", 0x07:"seven", 0x08:"eight", 0x09:"nine",
           0x0a:"a", 0x0b:"b", 0x0c:"c", 0x0d:"d", 0x0e:"e", 0x0f:"f"}
    for nums in tqdm.tqdm(itertools.product(itos.keys(), repeat=BLOCKS_SIZE)):
        sentence = f"{sentence_prefix} {', '.join(itos[num] for num in nums[:-1])}, and {itos[nums[-1]]}."
        hash_true = hashlib.sha256(bytes(sentence, "utf8")).hexdigest()
        guessed_prefix = "".join(f"{n:x}" for n in nums)
        true_prefix = hash_true[:BLOCKS_SIZE]
        if guessed_prefix == true_prefix:
            print("collision")
            print(sentence)
            print(hash_true)
Re:The SHA256 for this sentence begins with: one, eight, two... by aib on Monday September 11, 2023 @03:41PM (#37472588)
Indeed, this is how I did it. 2^28 is around 270 million. With little more than a handful options, it should be possible. Although I have to say, it turned out to be more difficult than I'd initially thought. Maybe it's better to think of it as 28 different boolean choices.

  echo -n "Indeed. This is how I managed to do it. 2^28 is around 300 million. With only a handful options, it's possible. Although, I must say that it turned out to be more difficult than I'd initially thought. Perhaps it's better to think of it as 28 different alternatives." | sha256sum
Re:The SHA256 for this sentence begins with: one, eight, two... by Alextigtig on Monday September 11, 2023 @09:14PM (#37475831)
This is crazy! The hash of this comment once again begins 182a7c9!!! Well done indeed!
Re:The SHA256 for this sentence begins with: one, eight, two... by petercooper on Monday September 11, 2023 @11:59AM (#37469227)
I just did an extremely lazy version of that and posted a reply of "And the SHA-1 digest (in hex) of this tweet starts BEEF" - https://twitter.com/cooperx86/status/1701261047917633846

Basically I had several substitutions around words, case, punctuation, etc. and just ran it until it found some hits. Quite easy with just four characters though but was only a proof of concept.

Re:The SHA256 for this sentence begins with: one, eight, two... by JamesSwift on Monday September 11, 2023 @12:15PM (#37469462)
I think this is a really good usecase for chatGPT to generate a massive number of variations that you then feed into a validation function
Re:The SHA256 for this sentence begins with: one, eight, two... by hinkley on Monday September 11, 2023 @12:46PM (#37469936)
All we are demonstrating here is why Sha256 is 256 bits and not 32 bits. We have trivially identified collisions for the first 28 bits of the output, which is only 11% of the entire hash size.

Difficulty of collisions roughly doubles for each additional bit. Imagine we had a SHA32, that would be 16 times harder to achieve a collision. SHA256 is 43 with 67 zeroes behind it more difficult than the examples here.

Re:The SHA256 for this sentence begins with: one, eight, two... by rawling on Monday September 11, 2023 @12:51PM (#37470029)
Yeah, I forgot how many bits were in a hex digit and made it seem much harder than it really was to myself.
Re:The SHA256 for this sentence begins with: one, eight, two... by hughesjj on Tuesday September 12, 2023 @02:30AM (#37477514)
I also mess up base16 and either base 256 or base64 when doing Feynman estimates
Re:The SHA256 for this sentence begins with: one, eight, two... by nstbayless on Monday September 11, 2023 @04:04PM (#37472877)
It's possible that the tweets were actually produced together somehow. This might buy just enough search space between the two of them.
Re:The SHA256 for this sentence begins with: one, eight, two... by kazinator on Monday September 11, 2023 @11:02AM (#37468311)
What are the chances of that? From the perspective of one specific sentence: one in 7 digits of hex: 16 * 7 = 268,435,456.
[dead]
Re:The SHA256 for this sentence begins with: one, eight, two... by krackers on Monday September 11, 2023 @03:16PM (#37472301)
Fyi your comment was dead on arrival, and seems many of your past ones are as well. I'd email dang and ask if you've tripped some spam filter.
Re:The SHA256 for this sentence begins with: one, eight, two... by johndough on Monday September 11, 2023 @12:50PM (#37470006)
It's not too difficult. All you need is to generate many variations of potential words and check whether the sha256 hash matches the wanted leading characters. For example, check this text.
Re:The SHA256 for this sentence begins with: one, eight, two... by isp on Monday September 11, 2023 @01:18PM (#37470408)

    $ echo -n $'It\'s not too difficult. All you need is to generate many variations of potential words and check whether the sha256 hash matches the wanted leading characters. For example, check this text.' | sha256sum
    182a7c9d2e99162688aaaf3f97638edd7d06f8d295e456c7bb1f16abf3a8f70c  -
Re:The SHA256 for this sentence begins with: one, eight, two... by wppick on Monday September 11, 2023 @04:18PM (#37473071)
Isn't this kind of the same thing that crypto miners do?
Re:The SHA256 for this sentence begins with: one, eight, two... by acchow on Monday September 11, 2023 @04:52PM (#37473539)
Yes except Bitcoin does double SHA (a second round of SHA on the first result)
Re:The SHA256 for this sentence begins with: one, eight, two... by stainablesteel on Monday September 11, 2023 @03:19PM (#37472335)
can we get this guy to pass a captcha? i've got questions
Re:The SHA256 for this sentence begins with: one, eight, two... by CobrastanJorji on Monday September 11, 2023 @07:09PM (#37474924)
Well played.

More seriously, is there a really good, open source library that generates many slight variations of an input block of text?

Re:The SHA256 for this sentence begins with: one, eight, two... by TylerE on Monday September 11, 2023 @07:19PM (#37475003)
Llama?
Re:The SHA256 for this sentence begins with: one, eight, two... by mcmoor on Tuesday September 12, 2023 @02:21AM (#37477465)
What's the difference between "this sentence" and "this tweet" in this context?