Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Simple wrapper for crypto primitives like MessageDigest and HMAC
Objective-C
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src
test
README

README

*Introduction*

This is a Cocoa wrapper for cryptographic primitives like
MessageDigest and Mac calculatation. It was written to be able to use
a Cocoa friendly API instead of the lower level OpenSSL or
CommonCrypto code.

The wrappers for with 'providers' to implement the actual crypto
operations. On Leopard and iPhone there is a CommonCrypto provider and
on older OS X versions you can fall back to the OpenSSL provider.

*Examples*

The following code calculates a HMAC SHA1 digest:

Mac* mac = [Mac macWithAlgorithm: @"SHA1" key: [@"Secret" dataUsingEncoding: NSASCIIStringEncoding]];
[mac updateWithString: @"Hello, world!" encoding: NSASCIIStringEncoding];
NSData* digest = [mac digest];

The following code calculates an MD5 digest:

MessageDigest* messageDigest = [MessageDigest messageDigestWithAlgorithm: @"SHA1"];
[messageDigest updateWithString: @"Hello, world!" encoding: NSASCIIStringEncoding];
NSData* digest = [messageDigest digest];

*Todo*

The Mac code uses the CommonCrypto library while the MessageDigest
code uses OpenSSL. Use CommonCrypto for both so that the code will
also work on the iPhone.
Something went wrong with that request. Please try again.