Latest 0.2.3
Homepage https://github.com/pelletier/TPCocoaGPG
License MIT
Platforms osx 10.9
Authors

Pod Version
Pod Platform
License

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.

Installation

The recommended way to install this library is CocoaPods:

pod 'TPCocoaGPG', :git => 'https://github.com/pelletier/TPCocoaGPG.git', :branch => :master

Usage

See TPCocoaGPG.h for the full API. See
TPCocoaGPGSpecs.m for usage examples.

Initialization

#import <TPCocoaGPG.h>
TPCocoaGPG* gpg = [[TPCocoaGPG] initGpgPath:@"/usr/local/bin/gpg" andHome:@"/tmp"];

List keys

NSArray* keys = [gpg listPublicKeys];
NSArray* keys = [gpg listSecretKeys];

Load key by fingerprint

TPGPGKey* key = [gpg getPublicKeyWithFingerprint:@"F2479DE6CFB6B695"];
TPGPGKey* key = [gpg getSecretKeyWithFingerprint:@"F2479DE6CFB6B695"];

Encrypt

NSData* encrypted = [gpg encryptData:data withKey:key andPassphrase:@"pass"];
NSData* encrypted = [gpg encryptData:data withKey:key];

Decrypt

NSData* decrypted = [gpg decryptData:data withKey:key andPassphrase:@"pass"];
NSData* decrypted = [gpg decryptData:data withKey:key];

Check if a passphrase unlocks a key

BOOL unlocks = [gpg checkIfPassphrase:@"pass" unlocksKey:key];

Import a key into the keyring

NSString* fingerprint = [gpg importIntoKeyring:key];

Generate keys pair

NSString* fingerprint = [gpg generateKeysWithLength:length
                                              email:@"[email protected]"
                                               name:@"example"
                                            comment:@"example"
                                      andPassphrase:@"qweqwe"];

Export a key

Armored ASCII output.

NSString* fingerprint = [gpg generateKeysWithLength:length
                                              email:@"[email protected]"
                                               name:@"example"
                                            comment:@"example"
                                      andPassphrase:@"qweqwe"];
// can be Public or Private
TPGPGKey* key = [gpg getPublicKeyWithFingerprint:fingerprint];
NSData* data = [gpg exportKey:key];

Change passphrase

NSString* fingerprint = [gpg generateKeysWithLength:length
                                              email:@"[email protected]"
                                               name:@"example"
                                            comment:@"example"
                                      andPassphrase:@"qweqwe"];
TPGPGKey* key = [gpg getSecretKeyWithFingerprint:fingerprint];
[gpg changePassphraseFor:key withOldPassphrase:@"qweqwe" toNewPassphrase:@"foobar"];

Development

Install development dependencies: pod install.
Open the workspace and run the tests.

License

MIT. See LICENSE.

Latest podspec

{
    "name": "TPCocoaGPG",
    "version": "0.2.3",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "homepage": "https://github.com/pelletier/TPCocoaGPG",
    "authors": {
        "Thomas Pelletier": "[email protected]"
    },
    "summary": "OpenGPG wrapper for Cocoa",
    "source": {
        "git": "https://github.com/pelletier/TPCocoaGPG.git",
        "tag": "v0.2.3"
    },
    "platforms": {
        "osx": "10.9"
    },
    "osx": {
        "source_files": "TPCocoaGPG/*.{h,m}",
        "public_header_files": "TPCocoaGPG/*.h"
    }
}

Pin It on Pinterest

Share This