Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

can anyone help me in md5 pseuodo code??

Status
Not open for further replies.

mosfets.bjt

Junior Member level 3
Joined
Sep 25, 2007
Messages
27
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Activity points
1,605
can anybody plz convert this pseudo code into understandable C code??.
this is the pseudo code for md5 algorithm i found on wikipedia



//Note: All variables are unsigned 32 bits and wrap modulo 2^32 when calculating
var int[64] r, k

//r specifies the per-round shift amounts
r[ 0..15] := {7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22}
r[16..31] := {5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20}
r[32..47] := {4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23}
r[48..63] := {6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21}

//Use binary integer part of the sines of integers (Radians) as constants:
for i from 0 to 63
k := floor(abs(sin(i + 1)) × (2 pow 32))

//Initialize variables:
var int h0 := 0x67452301
var int h1 := 0xEFCDAB89
var int h2 := 0x98BADCFE
var int h3 := 0x10325476

//Pre-processing:
append "1" bit to message
append "0" bits until message length in bits ≡ 448 (mod 512)
append bit /* bit, not byte */ length of unpadded message as 64-bit little-endian integer to message

//Process the message in successive 512-bit chunks:
for each 512-bit chunk of message
break chunk into sixteen 32-bit little-endian words w, 0 ≤ i ≤ 15

//Initialize hash value for this chunk:
var int a := h0
var int b := h1
var int c := h2
var int d := h3

//Main loop:
for i from 0 to 63
if 0 ≤ i ≤ 15 then
f := (b and c) or ((not b) and d)
g := i
else if 16 ≤ i ≤ 31
f := (d and b) or ((not d) and c)
g := (5×i + 1) mod 16
else if 32 ≤ i ≤ 47
f := b xor c xor d
g := (3×i + 5) mod 16
else if 48 ≤ i ≤ 63
f := c xor (b or (not d))
g := (7×i) mod 16

temp := d
d := c
c := b
b := b + leftrotate((a + f + k + w[g]) , r)
a := temp

//Add this chunk's hash to result so far:
h0 := h0 + a
h1 := h1 + b
h2 := h2 + c
h3 := h3 + d

var int digest := h0 append h1 append h2 append h3 //(expressed as little-endian)

//leftrotate function definition
leftrotate (x, c)
return (x << c) or (x >> (32-c));

Note: Instead of the formulation from the original RFC 1321 shown, the following may be used for improved efficiency (useful if assembly language is being used - otherwise, the compiler will generally optimize the above code. Since each computation is dependent on another in these formulations, this is often slower than the above method where the nand/and can be parallelised):

(0 ≤ i ≤ 15): f := d xor (b and (c xor d))
(16 ≤ i ≤ 31): f := c xor (d and (b xor c))

Added after 1 minutes:

working c code, that is, with correct encryption of md5
 

done!!!
by my self

thx for not helping me
 

can you help me by giving me the code you made...i need it for my project
mail it at umair.bukhari91@gmail.com if you can!!
thanks
 

what is your project? and in which language do u need it?
 

my project is to brute force the md5 algorithm on mpi clusters!!!!
but for that i first need a working code that works on a single machine atleast!
i need it in matlab but c++ will be ok too!
 

ya i do have it in C but rite now i am out of my home city. Whenever i will come back i will mail it to you. Btw, doing md5 bruteforce on FPGA is lot more fun then on mpi clusters. and offcourse much faster. whatever, i will send it to you soon inshAllah.
 

do you have the brute forcing code???
and thanks a lot it would be a big help...i am little short on the deadline!!!!
when will you be able to mail it to me?
 

I have 2 codes in different languages. 1 is in C, which only asks for input and returns output in md5 form,

other one is in verilog, it is a set of 100 verilog files, in which brute force operation along with pipe lining and parallel processing is done.

I will be able to mail you the C code somewhere near mid of this month

Moreover, please come on to skype if you want to message me. Because, i dont use edaboard too frequently. I have same ID in skype as here
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top