views:

40

answers:

2

I am trying to create a serial number checker in an app that I am writing, and it uses cryptography to encode the name and entered number against what it actually should be. I am familiar with the SHA1CryptoServiceProvider used in C#, but is there anything like this in Objective-C?

Here is sample code from C# that I want to convert to Objective-C:

string license = txtnLicense.Text;
        SHA1CryptoServiceProvider provider = new SHA1CryptoServiceProvider();
        string finalLicense = BitConverter.ToString(provider.ComputeHash(bytes));
        bool isGood = (BitConverter.ToString(provider.ComputeHash(bytes)).Replace("-", "") == license.Replace("-", ""));
+2  A: 

using openssl for license keys shows how to use SHA1. It may be a good start.

neoneye
Thank you! I will definitely have a go at it.
PumaSpeed
+3  A: 

Mac OS X comes with an easy-to-use encryption and hashing library built-in called CommonCrypto. You don't have to link against anything special to use it. See the headers in /usr/include/CommonCrypto for its interface and CC_SHA1(3cc) for docs.

Peter Hosey
Thank you, I didn't realize that either, I will look at that as well!
PumaSpeed