• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Help with SHA class
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with SHA class


  • Subject: Re: Help with SHA class
  • From: Ken Tozier <email@hidden>
  • Date: Thu, 4 Jun 2009 18:03:13 -0400


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 (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Help with SHA class
      • From: Michael Ash <email@hidden>
References: 
 >Re: Help with SHA class (From: Greg Guerin <email@hidden>)

  • Prev by Date: NSToolbarItem bindings crash
  • Next by Date: Re: Help with SHA class
  • Previous by thread: Re: Help with SHA class
  • Next by thread: Re: Help with SHA class
  • Index(es):
    • Date
    • Thread