在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):krzyzanowskim/ObjectivePGP开源软件地址(OpenSource Url):https://github.com/krzyzanowskim/ObjectivePGP开源编程语言(OpenSource Language):Objective-C 89.9%开源软件介绍(OpenSource Introduction):ObjectivePGP is an implementation of OpenPGP protocol for iOS and macOS. OpenPGP is the most widely used email encryption standard. It is defined by the OpenPGP Working Group of the Internet Engineering Task Force (IETF). Here is the blog post story. How do I get involved?You want to help, great! Go ahead and fork our repo, make your changes and send us a pull request. ContributionYou are welcome to contribute. See CONTRIBUTING.md The licenseThe ObjectivePGP stays under a dual license:
Not sure what to choose? check FAQ InstallationSwift Package Manager
CocoaPods
FrameworksObjectivePGP comes with the Frameworks for the latest release, you can copy and embed in your project: UsageObjective-C #import <ObjectivePGP/ObjectivePGP.h> Swift import ObjectivePGP Read keys (private or public)NSArray<PGPKey *> *keys = [ObjectivePGP readKeysFromPath:@"/path/to/key.asc" error:nil]; let keys = try ObjectivePGP.readKeys(fromPath: "/path/to/key.asc") KeyringKeyring is a storage (in memory or on disk) that keep all sorts of PGP keys. PGPKeyring *keyring = ObjectivePGP.defaultKeyring;
PGPKeyring *keyring = [[PGPKeyring alloc] init];
NSArray<PGPKey *> *allKeys = keyring.keys;
[keyring importKeys:@[key]];
[keyring deleteKeys:@[key]];
[keyring importKey:@"979E4B03DFFE30C6" fromPath:@"/path/to/secring.gpg"];
PGPKey *key = [keyring findKeyWithIdentifier:@"979E4B03DFFE30C6"];
NSArray<PGPKey *> keys = [pgp findKeysForUserID:@"Name <[email protected]>"]; let keyring = ObjectivePGP.defaultKeyring
let keyring = Keyring()
let allKeys = keyring.keys
keyring.import(keys: [key])
keyring.delete(keys: [key])
keyring.import(keyIdentifier:"979E4B03DFFE30C6", fromPath:"/path/to/secring.gpg")
if let key = keyring.findKey("979E4B03DFFE30C6") {
// key found in keyring
}
keyring.findKeys("Name <[email protected]>").forEach(key) {
// process key
} Export keys (private or public)// Write keyring to file
[[keyring export:error] writeToURL:[NSURL fileURLWithString:@"keyring.gpg"]];
// Public keys data
NSData *publicKeys = [keyring exportKeysOfType:PGPKeyTypePublic error:nil]; // Write keyring to file
try keyring.export().write(to: URL(fileURLWithPath: "keyring.gpg"))
// Public keys (Data)
let publicKeys = keyring.exportKeys(of: .public) Sign & verify data (or file)Sign a data with a key: NSData *signature = [ObjectivePGP sign:fileContent detached:YES usingKeys:@[key] passphraseForKey:nil error:nil];
[ObjectivePGP verify:fileContent withSignature:signature usingKeys:@[key] passphraseForKey:nil error:nil]; let signature = try ObjectivePGP.sign(encryptedBin, detached:true, using: [key1])
try ObjectivePGP.verify(encryptedBin, withSignature: signature, using: [key1]) Encrypt & DecryptNSData *encrypted = [ObjectivePGP encrypt:fileContent addSignature:YES usingKeys:@[key] passphraseForKey:nil error:nil];
[ObjectivePGP decrypt:encrypted andVerifySignature:YES usingKeys:@[key] passphraseForKey:nil error:nil]; let encrypted = try ObjectivePGP.encrypt(fileContent), addSignature: true, using: [key1, key2])
let decrypted = try ObjectivePGP.decrypt(encrypted, andVerifySignature: true, using: [key1]) Generate new key pairPGPKeyGenerator *generator = [[PGPKeyGenerator alloc] init];
PGPKey *key = [generator generateFor:@"Marcin <[email protected]>" passphrase:nil];
NSData *publicKeyData = [key export:PGPKeyTypePublic error:nil];
NSData *secretKeyData = [key export:PGPKeyTypeSecret error:nil]; let key = KeyGenerator().generate(for: "[email protected]", passphrase: "password")
let publicKey = try key.export(keyType: .public)
let secretKey = try key.export(keyType: .secret) ASCII ArmorASCII armor is a binary-to-textual encoding converter. ASCII armor involves encasing encrypted messaging in ASCII so that they can be sent in a standard messaging format such as email. Example:
Class NSString *armoredKey = [PGPArmor armoredData:encrypted as:PGPArmorPublicKey]; let armoredKey = Armor.armored(Data(), as: .publicKey) When convert manually, it is important to use right
For any result of encryption the type is ChangelogSee CHANGELOG Known limitations:
Security AuditTo date the ObjectivePGP code base has undergone a complete security audit from Cure53. AcknowledgmentThis product uses software developed by the OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org/) Author |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论