On Wed, 12 Dec 2018 at 19:10, Richard O'Keefe <[email protected]> wrote:
> PS: converting the result of MD5 hashMessage: to hex is a total waste of > time. > Just ask: > - is the first byte zero? > - is the second byte zero? > - is the third byte less than 16? > Good point. cheers -ben > > On Thu, 13 Dec 2018 at 00:07, Richard O'Keefe <[email protected]> wrote: > >> This is the puzzle where you have to find the smallest integer such that >> '<some salt>' , (that integer) printString has an MD5 hash beginning with >> 5 hexadecimal zeros? >> >> Brute force is just fine. Calling libnettle's MD5 functions from a C >> program, it found the right answer in under 0.2 seconds on a cheap laptop. >> If using the MD5 class in Pharo doesn't take a reasonable time, you may >> find that (MD5 isPluginAvailable) is false. On my cheap laptop, the >> obvious code took 30 seconds to find the right answer, which surely means >> that the plugin is *not* available. But there is absolutely no point in >> looking for anything faster. >> >> So, >> (0 to: 1000000) findFirst: [:n | |digest| >> digest := MD5 hashMessage: 'YOUR SALT GOES HERE' , n printString. >> ... bytes begins with 00000 ...] >> >> Linear search. >> Compute string. >> Compute its MD5 hash. >> Check the result. >> >> The only time-consuming thing was browsing the MD5 class (and its >> superclass HashFunction) to figure out the interface. >> >> Now it *could* have turned out to be too slow to be useful, in which >> case another strategy would have been needed. But it didn't. >> (I started with a rather smaller bound to get an idea of how fast it >> was, and it was fast enough.) >> >> >> >> On Mon, 10 Dec 2018 at 00:30, Roelof Wobben <[email protected]> wrote: >> >>> Helllo, >>> >>> a question about day4 of 2015 >>> is it right that I can only solve this bruteforece >>> so begin at for example 1 , encode it, check for 5 zeros if found then I >>> have found it otherwise increase the counter and do it again >>> https://adventofcode.com/2015/day/4 >>> >>> Regards, >>> >>> Roelof >>> >>>
