Question: I've made a cocoa mac application which needs to check if a serial number/license key is correct, i'm unsure what type of algorithms would be the best for this.

Lets say i have this serial number:
4829-1234-4321-1234-4326-5232 or any set of 4 numbers.
I was thinking about using an algorithm like if the first set of the license key is divisible by 5, second by 10, third by 24.... but i'm not sure if this is the best way to go about it.

I would also need to generate the keys in PHP.

Any help is appreciated

Answer: 
There are a number of options available in this arena. One option I would consider is implementing partial serial number verification (<http://www.brandonstaggs.com/2007/07/26/implementing-a-partial-serial-number-verification-system-in-delphi/>) The link is written for Delphi developers but the concept is a good one and can be implemented in any language.
The general idea I've heard is using [public-key cryptography](http://en.wikipedia.org/wiki/Public-key_cryptography). 

You generate a key pair, and put one of the keys into your application; the other is your private key. You collect a bit of information from a licensee, such as name and email address. You hash that, and encrypt the hash with your private key, then send the encrypted result to the licensee as the license code. 

The licensee is prompted by your application to enter the same information that you collected, along with the code. Now your application simply uses the key embedded in it (the "public" key) to decrypt the code, which retrieves the hash; performs a hash on the name and email; and compares the two results. If they match, the code is valid (or the person got awfully lucky).

Allan Odgaard did a swell writeup that should walk you through everything you need to do: [SIGPIPE 13: OpenSSL for License Keys](http://sigpipe.macromates.com/2004/09/05/using-openssl-for-license-keys/)

(Hope I'm not misunderstanding the question.)