Objective-C wrapper around GPG.
This library aims to be a simple, easy to use library to deal with GPG. It does not try to be complete, nor to get rid of the GPG binary.
The recommended way to install this library is CocoaPods:
pod 'TPCocoaGPG', :git => 'https://github.com/pelletier/TPCocoaGPG.git', :branch => :master
See TPCocoaGPG.h for the full API. See TPCocoaGPGSpecs.m for usage examples.
#import <TPCocoaGPG.h>
TPCocoaGPG* gpg = [[TPCocoaGPG] initGpgPath:@"/usr/local/bin/gpg" andHome:@"/tmp"];
NSArray* keys = [gpg listPublicKeys];
NSArray* keys = [gpg listSecretKeys];
TPGPGKey* key = [gpg getPublicKeyWithFingerprint:@"F2479DE6CFB6B695"];
TPGPGKey* key = [gpg getSecretKeyWithFingerprint:@"F2479DE6CFB6B695"];
NSData* encrypted = [gpg encryptData:data withKey:key andPassphrase:@"pass"];
NSData* encrypted = [gpg encryptData:data withKey:key];
NSData* decrypted = [gpg decryptData:data withKey:key andPassphrase:@"pass"];
NSData* decrypted = [gpg decryptData:data withKey:key];
BOOL unlocks = [gpg checkIfPassphrase:@"pass" unlocksKey:key];
NSString* fingerprint = [gpg importIntoKeyring:key];
NSString* fingerprint = [gpg generateKeysWithLength:length
email:@"test@example.com"
name:@"example"
comment:@"example"
andPassphrase:@"qweqwe"];
Armored ASCII output.
NSString* fingerprint = [gpg generateKeysWithLength:length
email:@"test@example.com"
name:@"example"
comment:@"example"
andPassphrase:@"qweqwe"];
// can be Public or Private
TPGPGKey* key = [gpg getPublicKeyWithFingerprint:fingerprint];
NSData* data = [gpg exportKey:key];
NSString* fingerprint = [gpg generateKeysWithLength:length
email:@"test@example.com"
name:@"example"
comment:@"example"
andPassphrase:@"qweqwe"];
TPGPGKey* key = [gpg getSecretKeyWithFingerprint:fingerprint];
[gpg changePassphraseFor:key withOldPassphrase:@"qweqwe" toNewPassphrase:@"foobar"];
Install development dependencies: pod install
.
Open the workspace and run the tests.
MIT. See LICENSE.