Socoder -> Cobra -> Attempting Cobra MD5 function
|Posted : Sunday, 26 August 2007, 20:45|
I'm trying to write a function to create MD5 hashes in Cobra.
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?
|Posted : Monday, 27 August 2007, 02:55|
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.
Project Dollhouse on Github - Please fork!
|Posted : Monday, 27 August 2007, 08:44|
That helps a fair bit
I'll see if I have any luck.