围绕 GPG 的 Objective-C 封装。
这个库旨在成为简单、易于使用的库,以便处理 GPG。它并不试图全面,也不会删除 GPG 二进制文件。
安装此库的推荐方法是使用 CocoaPods
pod 'TPCocoaGPG', :git => 'https://github.com/pelletier/TPCocoaGPG.git', :branch => :master
请参阅 TPCocoaGPG.h 以获取完整 API。请参阅 TPCocoaGPGSpecs.m 以获取用法示例。
#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:@"[email protected]"
name:@"example"
comment:@"example"
andPassphrase:@"qweqwe"];
武装 ASCII 输出。
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];
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"];
安装开发依赖项: pod install
。打开工作区并运行测试。
MIT。请参阅 LICENSE。