123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|679|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Cobra -> Attempting Cobra MD5 function

Sun, 26 Aug 2007, 20:45
HoboBen
Hi,

I'm trying to write a function to create MD5 hashes in Cobra.
I've got the JavaScript MD5 source code (The C one was impossibly long!)

And this excellent info too.

Cobra can't yet take or return arrays with functions (though I have requested that), so a straight copy+paste hack job won't really work.

It hasn't been too difficult to follow the general code behind the MD5 function, but in that second link, I don't really get this bit:



What does that all mean, and how would I Cobra-ise it?
I sorta have a grasp of how that bit works, but I don't know what it's for, either.
What does "~" mean in C? How does the whole |&^~ thing work in the return part? Are these shorthand operations on some binary data or what?

Finally, what's the difference between a hex or base-64 encoded string?

Thank you,
Hobo

-=-=-
blog | work | code | more code
Mon, 27 Aug 2007, 02:55
Afr0
Never tried using MD5 myself, but based on that bit of code you posted, I can tell it appears to be equivalent to mathematical functions named F, G, H, I used in the algorithm. They are explained here under the section 'Algorithm'.

As for the operators, I can give you the standard C names for most of them, but it's too early in the morning for me to bother to do any proper research into how they work in this particular case;

& = Binary And (Can also be AddressOf, but doesn't seem to be in this case, since there aren't any pointers involved)
| = Inclusive Or
^ = Exclusive Or (Also referred to as Xor for BASIC users)
~ = One's compliment - This operator is unary (requires one operand) and has the efect of 'flipping' bits.

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Mon, 27 Aug 2007, 08:44
HoboBen
Thanks Afro,

That helps a fair bit

I'll see if I have any luck.

Cheers

-=-=-
blog | work | code | more code