An Objective-C interface for the PBKDF2 implementation in CommonCrypto.
Switch branches/tags
Nothing to show
Clone or download


Version Platform License

PBKDF2-Wrapper provides a very simple Objective-C interface for the CommonCrypto implementation of the PBKDF2 algorithm.


Derive Key

Derive an encryption key from a password. PBKDF2Result automatically handles creating a secure random salt, and calibrating the number of rounds to take approximately 100ms to derive the key.

NSString *password = ...;
PBKDF2Result *result = [[PBKDF2Result alloc] initWithPassword:password];
NSData *encryptionKey = result.derivedKey;

Save Configuration

Afterwards you can conveniently archive the configuration which includes information such the key length, salt, number of rounds, and the pseudo random function that was used when deriving the key.

[NSKeyedArchiver archiveRootObject:result.configuration

Load Saved Configuration

Next launch you can grab the archived configuration file and use that when deriving the key.

PBKDF2Configuration *configuration = [NSKeyedUnarchiver unarchiveObjectWithFile:@"/path/to/file"];

NSString *password = ...;
PBKDF2Result *result = [[PBKDF2Result alloc] initWithPassword:password
NSData *encryptionKey = result.derivedKey;

Explicit Configuration Creation

In addition you can also explicitly create the configuration using a number of helpful initializers. Here is an example:

NSData *salt = ...;

[[PBKDF2Configuration alloc] initWithSalt:salt


  1. Install via CocoaPods
pod 'PBKDF2-Wrapper'
  1. Import the public header
#import <PBKDF2-Wrapper/PBKDF2-Wrapper.h>


  • iOS 6.0
  • OSX 10.8
  • watchOS 2.0


Build Status

To run tests pull down the repository and run the following commands:

$ bundle install
$ bundle exec rake test:prepare
$ bundle exec rake


Joey Meyer


PBKDF2-Wrapper is available under the MIT license. See the LICENSE file for more info.