abarbatei / tomd5

work-in-progress MD5 hashing algorithm implemented in ”pure” Windows batch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tomd5

As a challenge to myself I wanted to implement the MD5 hashing algorithm in batch. The project is not finished and currently is not under active development.

The code

What was done

For the initial binary integer part of the sines of integers, witch would be something similar to:

for i from 0 to 63
    K[i] := floor(232 × abs(sin(i + 1)))
end for

I chose to precomputed and set the table.

This could have been done in batch, quite easelly actually, as there are many brave developers who tested their nervs and implemented all the necesary functions such as sin(x) and cos(x) in batch.

Several helper functions where needed and implemented:

  • a function that does unsigned right shift rfrs
  • as batch currently works with 32 bits signed integers only, a function to cast a value to a signed C2 byte was needed byte_cast

Reading the content of a file as hex is done using a trick with the Windows FC tool. Although this is not the chosen idiom of pure batch it is reasonably close enough.

Please remember, there are no arrays in batch. Arrays are mimicked using variables with array names. Example only the following variable declarations are fine vector[0] and vectori[7]. Think of them as declaring vector_1 and vector_7.

TODO

  • the limitations regarding code blocks in parentheses ( ) have stopped me. I see the need for a double EnableDelayedExpansion. This may be mitigated using batch calls to other functions where the operation occurs. Must experiment to verify.

  • at this point the code sets up the initial variables needed and reads the file as bytes to the message variable.

Resources

About

work-in-progress MD5 hashing algorithm implemented in ”pure” Windows batch

License:MIT License


Languages

Language:Batchfile 100.0%