[erlang-questions] Request for comment or contributions

Barry Ezell <>
Thu Sep 4 16:17:29 CEST 2008

Hello Bengt,

Thank you very much for the suggestions.  I've commented the code
better to explain the intent of the module.  This is my first Erlang
program and I'm trying to prepare a talk on concurrency in Erlang to
be given in October.  The module is demonstration code for breaking
MD5 passwords using a brute-force approach.  For example, if the
string "hi" is hashed by erlang:md5, the program would partition every
2-character variant into as many arrays as processes to be spawned,
then each process would test the md5 hash of the character arrays
until "hi" is found as a match.  This is a contrived example but easy
enough to grasp for the purposes of a talk.

I have implemented all of the changes you suggested except for #1.
There is a reason why the list is reversed before next/3 is evaluated.
 The character array is examined in reverse order because the
increment of one character may affect the increment of the character
in front of it.  For instance, next("aaz") must yield "aba".  When
reversed, "z" is matched first, changed to "a", then the increment is
passed to the next character in the reversed array, thus changing "a"
to "b".  If I am missing something I should be doing differently,
please let me know.

The changes are posted at:

Thanks again,


On Thu, Sep 4, 2008 at 9:22 AM, Bengt Kleberg
<> wrote:
> Greetings,
> Unfortunately I do not understand what your program does. So this is a
> very low level comment.
> 1 If possible try to change next() to the following:
> next(L) ->
>  next(L, [], true).
> next([], L, _Incr) ->
>  lists:reverse(L);
> %% the rest as in your code
> Unless there is a specific reason to reverse before use the normal
> Erlang way is to reverse afterwards.
> 2 In partition_alphabet() I would use a tuple for Arr. Like this:
> Arr = {chr_array(CurChar, Len, min) , chr_array($z, Len, max)},
> and also change decrypt()'s fun to fun({Min,Max}) ->
> Lists are normally used for a variable amount of items. Here you always
> have 2 items.
> 3 As a personal habit I would change analyze() to use case instead of
> if. Like this:
> case Test =:= Crypted of
> true ->
> false ->
> end.
> This is just because I find if very different to other langugaes if.
> bengt
> On Wed, 2008-09-03 at 17:04 -0400, Barry Ezell wrote:
>> In my request for comments post yesterday, I forgot to mention that
>> the code can be viewed at the following URL without requiring a "git
>> clone".
>> http://github.com/btedev/erlang_md5crack/tree/master/pwd.erl
>> Thanks again for any suggestions.
>> _______________________________________________
>> erlang-questions mailing list
>> http://www.erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list