[Cuis-dev] Hello and MD5 hash weird behavior
Jeroen Kouwer
jeroen.kouwer at gmail.com
Sun Nov 9 07:20:51 PST 2025
Hallo Luciano,
Thanks for looking into this issue, and thanks for the hint to change
the #doWithIndex: to #withIndexDo: when using the MD5NonPrimitive! Also,
it took me some time to find out that there appears to be an MD5Plugin
that is doing the main work in the default situation.
Looking at the current Squeak I notices an MD5WithPrimitive and some
additional initialization calls. I've copied these deltas to the code
offered for Cuis and now it works as expected!
Yeah!
I've made a pull request with these changes on the
Cuis-Smalltalk-Cryptograpy repository [1]. However, I noticed that
garduino hasn't been active on github lately, so my hope is not very
high for the pull request to get accepted. We'll see.
The changes can be viewed in the - at the time of writing only - pull
request of [1], or you can fork my fork [2] of [1] and checkout the
fix/md5-with-primitive branch.
Regards,
Jeroen
[1] https://github.com/garduino/Cuis-Smalltalk-Cryptography
[2]
https://github.com/jermus67/Cuis-Smalltalk-Cryptography/tree/fix/md5-with-primitive
On 11/9/25 3:08 PM, Luciano Notarfrancesco via Cuis-dev wrote:
> Hi Jeroen,
> I just tried it on mac with the latest Cuis and I get the same results
> as you. However, using MD5NonPrimitive instead of MD5 I get the
> correct result (note that you will get a message not understood
> exception, because it sends the message #doWithIndex: that doesn’t
> exist, you just need to replace it with #withIndexDo:).
>
>
> On Sun, Nov 9, 2025 at 05:53 Jeroen Kouwer via Cuis-dev
> <cuis-dev at lists.cuis.st> wrote:
>
> Hello,
>
> I'm new to this list and new to Smalltalk development. I'm a software
> engineer by profession and grew up with Unix (SVR4), Pascal and C.
> Since
> then I've moved to Linux, Java and C++ and although I've read about
> Smaltalk and I have been intrigued with the idea behind it, I've
> never
> actually programmed in it.
>
> Until now.
>
> I've started The Cuis Book, together with the SBE and the Cuis Cook
> Book, and am currently trying to solve the first year of the
> Advent of
> Code (2015) in Smalltalk (the Cuis version [1]). The first three days
> went really well. The challenge came on day four: having to use
> MD5 hash
> calculation. Cuis, out of the box, doesn't come with an MD5 class. A
> little searching led me to the Cryptography package [2] and I
> installed
> the package using the File List.
>
> Side note: This package does not define a feature, so when next
> starting
> the image (provided having saved it) it throws you into the debugger.
> The package is recognized, but when checking for new versions it
> finds
> out that there's no feature defined (nil is not a valid feature) and
> this part of opening the image cannot handle that:
> ```
> UndefinedObject(Object)>>doesNotUnderstand: #isLaterThan:
> [] in ChangeSet class>>installNewUpdates:
> ...
> ```
> However, this can be solved by saving the package (open Installed
> Packeges); saving the package apparently adds the category as
> feature to
> the *.pck.st <http://pck.st>.
>
> Back to Cryptography and feature Cuis-System-Hashing (from the
> Cryptography package [2]): I cannot get the MD5 class to behave as I
> expect it to behave. I expect that each call to hashMessage with the
> same message results in the same hash, which it does in Squeak and
> Pharo
> (after some frustration I did some checking).
>
> After having loaded the package for the first time and executing
> it the
> results are as expected:
> ```
> ((MD5 new) hashMessage: 'abcdef609043') hex.
> '000001DBBFA3A5C83A2D506429C7B00E' .
> ```
> Executing it a second time results in:
> ```
> ((MD5 new) hashMessage: 'abcdef609043') hex.
> 'D1CE4AB38D6D9DC0E1FF789725EFA294' .
> ```
> Each consecutive execution results in a different value, which is not
> what I expected!
>
> (I've managed to solve day four by resorting to Squeak :o, sorry...)
>
> Does anyone has an idea why this calculation keeps on producing new
> values on each execution?
>
> Regards,
> Jeroen Kouwer
>
> P.S. I have observed the same behavior with Cuis 7.2 [3]
>
>
> [1] https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
>
> [2] https://github.com/garduino/Cuis-Smalltalk-Cryptography
>
> [3] https://github.com/Cuis-Smalltalk/Cuis7-2
>
> --
> Cuis-dev mailing list
> Cuis-dev at lists.cuis.st
> https://lists.cuis.st/mailman/listinfo/cuis-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20251109/a6b670bb/attachment.htm>
More information about the Cuis-dev
mailing list