[Cuis-dev] Hello and MD5 hash weird behavior

Martin McClure martin at hand2mouse.com
Sat Nov 8 16:17:39 PST 2025


Well, I don't know for sure, since I haven't looked at the code or trid 
to use it, but...

If it gives the correct answer the first time, and not on subsequent 
times, it sounds very much like it could be that the hash state is not 
being reset between tries, so what you're getting is the hash of your 
message concatenated N times. Perhaps there is an initialization message 
that is not getting sent?

Regards,

-Martin

On 11/8/25 2:52 PM, Jeroen Kouwer via Cuis-dev 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.
>
> 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
>


More information about the Cuis-dev mailing list