On Jun 4, 2009, at 1:35 PM, Greg Guerin wrote:
Why are you writing this algorithm?
Practice mostly. I wrote a MySQL connector class in Cocoa, but had to copy the SHA and password scrambling code from the MySQL source. It works, but it's really ugly and I wanted to take a crack at that part of the code to make it more Cocoa native.
If you're writing it in order to learn about hash algorithms, then I think it makes more sense for you to debug your code yourself, as unhelpful as that may seem to be. I also suggest reading sources other than Wikipedia, not necessarily because Wikipedia might be wrong or have a typo, but because there might be more detailed step- by-step explanations elsewhere on the web. Or look at the public domain ones and see how they differ from yours.
My algorithm seem pretty much like those I've looked at (and the one at Wikipedia) I made a few minor adjustments (using a switch rather than 4 separate loops etc...) but it seems like it should be pretty easy.
You might also try running your code on a machine that's actually big-endian, to see what happens. Unless you already are.
No access to a big endian machine
Iff you're running it on an Intel CPU, simply compile the code for ppc and use the 'arch' command to run that slice instead of the native slice. If it doesn't produce the same output, then you have an implied-endian bug. If it does produce the same output, you still have a bug.
Is it possible to compile a single class in a project to PPC while everything else in the project compiles to Intel?
If you're using an Intel CPU, maybe try finding a little-endian implementation of the algorithm.
No luck on that front.
BTW, your code should probably be using the type names UInt32 and UInt64, instead of making assumptions about sizes. There are also places where you use the constant 4 instead of sizeof(UInt32). Though these may not affect this implementation, they seem questionable to me.
I generally go back and clean stuff like that up once I get the basic functionality working.
-Ken _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com