{"id":15160672,"url":"https://github.com/krzyzanowskim/objectivepgp","last_synced_at":"2025-05-16T09:00:21.962Z","repository":{"id":19034906,"uuid":"22259463","full_name":"krzyzanowskim/ObjectivePGP","owner":"krzyzanowskim","description":"ObjectivePGP is an open-source library for iOS and macOS that provides developers with tools for implementing OpenPGP encryption and decryption, digital signing, and signature verification in their applications, thereby enhancing security and data integrity.","archived":false,"fork":false,"pushed_at":"2024-05-20T15:48:44.000Z","size":314801,"stargazers_count":701,"open_issues_count":4,"forks_count":113,"subscribers_count":23,"default_branch":"main","last_synced_at":"2025-05-11T13:28:59.179Z","etag":null,"topics":["encryption","framework","ios","macos","macos-swift","objective-c","openpgp","osx","pgp","swift"],"latest_commit_sha":null,"homepage":"https://objectivepgp.com","language":"Objective-C","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/krzyzanowskim.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-third-party.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-07-25T14:21:11.000Z","updated_at":"2025-05-10T18:00:58.000Z","dependencies_parsed_at":"2023-02-17T23:15:46.662Z","dependency_job_id":"80133888-0013-41e7-9f65-a91d228885cc","html_url":"https://github.com/krzyzanowskim/ObjectivePGP","commit_stats":{"total_commits":956,"total_committers":20,"mean_commits":47.8,"dds":0.05648535564853552,"last_synced_commit":"29d7a531f00140224434d0cbaf5f2f21168bfe9c"},"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krzyzanowskim%2FObjectivePGP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krzyzanowskim%2FObjectivePGP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krzyzanowskim%2FObjectivePGP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krzyzanowskim%2FObjectivePGP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krzyzanowskim","download_url":"https://codeload.github.com/krzyzanowskim/ObjectivePGP/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254501548,"owners_count":22081526,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["encryption","framework","ios","macos","macos-swift","objective-c","openpgp","osx","pgp","swift"],"created_at":"2024-09-26T23:05:13.495Z","updated_at":"2025-05-16T09:00:19.169Z","avatar_url":"https://github.com/krzyzanowskim.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"![objectivepgp](https://user-images.githubusercontent.com/758033/27697465-a355ca34-5cf4-11e7-9470-ee1ee98eedd9.png)\n\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/ObjectivePGP.svg)](https://cocoapods.org/pods/ObjectivePGP)\n[![Swift Package Manager compatible](https://img.shields.io/badge/SPM-compatible-brightgreen.svg?style=flat\u0026colorA=28a745\u0026\u0026colorB=4E4E4E)](https://github.com/apple/swift-package-manager)\n[![Platform](https://img.shields.io/badge/Platforms-iOS%20%7C%20macOS-4E4E4E.svg?colorA=28a745)](#installation)\n[![Twitter](https://img.shields.io/badge/twitter-@krzyzanowskim-blue.svg?style=flat)](http://twitter.com/krzyzanowskim)\n\n\n**ObjectivePGP** is an implementation of [OpenPGP](https://en.wikipedia.org/wiki/Pretty_Good_Privacy#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).\n\nHere is the [blog post](https://blog.krzyzanowskim.com/2014/07/31/short-story-about-openpgp-for-ios-and-os-x-objectivepgp/) story.\n\n## How do I get involved?\n\nYou want to help, great! Go ahead and fork our repo, make your changes and send us a pull request.\n\n## Contribution\n\nYou are welcome to contribute. See [CONTRIBUTING.md](https://github.com/krzyzanowskim/ObjectivePGP/blob/master/CONTRIBUTING.md)  \nPlease create [Pull Request](https://github.com/krzyzanowskim/ObjectivePGP/pulls).\n\n## The license\n\nThe ObjectivePGP stays under a dual license:\n\n- Free for non-commercial use, covered by the variant of BSD license. That means you have to mention Marcin Krzyżanowski as the original author of this code and reproduce the [LICENSE](./LICENSE.txt) text inside your app.\n\n- Commercial-use license to use in commercial products. Please bear in mind that some free products remain commercial products. Please contact me via [email](https://www.krzyzanowskim.com) for details.\n\n\nNot sure what to choose? check [FAQ](https://github.com/krzyzanowskim/ObjectivePGP/wiki/FAQ)\n\n## Installation\n\n### Swift Package Manager\n\n```\ndependencies: [\n    .package(url: \"https://github.com/krzyzanowskim/ObjectivePGP.git\", .upToNextMinor(from: \"0.99.4\"))\n]\n```\n\n### CocoaPods\n\n````\npod 'ObjectivePGP'\n````\n\n### Frameworks\n\nObjectivePGP comes with the [Frameworks](./Frameworks) for the latest release, you can copy and embed in your project:\n\n- [ObjectivePGP.framework](Frameworks/)\n- [ObjectivePGP.xcframework](Frameworks/)\n\n## Usage\n\nObjective-C\n```objective-c\n#import \u003cObjectivePGP/ObjectivePGP.h\u003e\n```\n\nSwift\n```swift\nimport ObjectivePGP\n```\n\n##### Read keys (private or public)\n\n```objective-c\nNSArray\u003cPGPKey *\u003e *keys = [ObjectivePGP readKeysFromPath:@\"/path/to/key.asc\" error:nil];\n```\n\n```swift\nlet keys = try ObjectivePGP.readKeys(fromPath: \"/path/to/key.asc\")\n```\n\n##### Keyring\n\nKeyring is a storage (in memory or on disk) that keep all sorts of PGP keys.\n\n```objective-c\nPGPKeyring *keyring = ObjectivePGP.defaultKeyring;\nPGPKeyring *keyring = [[PGPKeyring alloc] init];\n\nNSArray\u003cPGPKey *\u003e *allKeys = keyring.keys;\n[keyring importKeys:@[key]];\n[keyring deleteKeys:@[key]];\n\n[keyring importKey:@\"979E4B03DFFE30C6\" fromPath:@\"/path/to/secring.gpg\"];\nPGPKey *key = [keyring findKeyWithIdentifier:@\"979E4B03DFFE30C6\"];\nNSArray\u003cPGPKey *\u003e keys = [pgp findKeysForUserID:@\"Name \u003cemail@example.com\u003e\"];\n```\n\n```swift\nlet keyring = ObjectivePGP.defaultKeyring\nlet keyring = Keyring()\n\nlet allKeys = keyring.keys\nkeyring.import(keys: [key])\nkeyring.delete(keys: [key])\n\nkeyring.import(keyIdentifier:\"979E4B03DFFE30C6\", fromPath:\"/path/to/secring.gpg\")\nif let key = keyring.findKey(\"979E4B03DFFE30C6\") {\n\t// key found in keyring\n}\n\nkeyring.findKeys(\"Name \u003cemail@example.com\u003e\").forEach(key) {\n\t// process key\n}\n```\n\n##### Export keys (private or public)\n\n```objective-c\n// Write keyring to file\n[[keyring export:error] writeToURL:[NSURL fileURLWithString:@\"keyring.gpg\"]];\n\n// Public keys data\nNSData *publicKeys = [keyring exportKeysOfType:PGPKeyTypePublic error:nil];\n```\n\n```swift\n// Write keyring to file\ntry keyring.export().write(to: URL(fileURLWithPath: \"keyring.gpg\"))\n\n// Public keys (Data)\nlet publicKeys = keyring.exportKeys(of: .public)\n```\n\n##### Sign \u0026 verify data (or file)\n\nSign a data with a key:\n\n```objective-c\nNSData *signature = [ObjectivePGP sign:fileContent detached:YES usingKeys:@[key] passphraseForKey:nil error:nil];\n[ObjectivePGP verify:fileContent withSignature:signature usingKeys:@[key] passphraseForKey:nil error:nil];\n```\n\n```swift\nlet signature = try ObjectivePGP.sign(encryptedBin, detached:true, using: [key1])\ntry ObjectivePGP.verify(encryptedBin, withSignature: signature, using: [key1])\n```\n\n##### Encrypt \u0026 Decrypt\n\n```objective-c\nNSData *encrypted = [ObjectivePGP encrypt:fileContent addSignature:YES usingKeys:@[key] passphraseForKey:nil error:nil];\n[ObjectivePGP decrypt:encrypted andVerifySignature:YES usingKeys:@[key] passphraseForKey:nil error:nil];\n```\n\n```swift\nlet encrypted = try ObjectivePGP.encrypt(fileContent), addSignature: true, using: [key1, key2])\nlet decrypted = try ObjectivePGP.decrypt(encrypted, andVerifySignature: true, using: [key1])\n```\n\n##### Generate new key pair\n\n```objective-c\nPGPKeyGenerator *generator = [[PGPKeyGenerator alloc] init];\nPGPKey *key = [generator generateFor:@\"Marcin \u003cmarcin@example.com\u003e\" passphrase:nil];\nNSData *publicKeyData = [key export:PGPKeyTypePublic error:nil];\nNSData *secretKeyData = [key export:PGPKeyTypeSecret error:nil];\n```\n\n```swift\nlet key = KeyGenerator().generate(for: \"marcin@example.com\", passphrase: \"password\")\nlet publicKey = try key.export(keyType: .public)\nlet secretKey = try key.export(keyType: .secret)\n```\n\n#### ASCII Armor\n\nASCII 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.\n\nExample:\n\n```\n-----BEGIN PGP PUBLIC KEY BLOCK-----\nComment: For more info see https://www.objectivepgp.org\n\n[...]\n-----END PGP PUBLIC KEY BLOCK-----\n```\n\nClass `PGPArmor` can be used to convert binary format to ASCII format\n\n```objective-c\nNSString *armoredKey = [PGPArmor armoredData:encrypted as:PGPArmorPublicKey];\n```\n\n```swift\nlet armoredKey = Armor.armored(Data(), as: .publicKey)\n```\n\nWhen convert manually, it is important to use right `PGPArmorType` value that define the header. It may be a tricky part so here's the cheatsheet:\n\n| Type data  | PGPArmorType          | Example |\n| ---------- | --------------------- |-------- |\n| Encrypted  | `PGPArmorMessage` | `Armor.armored(ObjectivePGP.encrypt(...), as: .message)` |\n| Decrypted  | `PGPArmorMessage` | `Armor.armored(ObjectivePGP.decrypt(...), as: .message)` |\n| Public key | `PGPArmorTypePublic`  | `Armor.armored(key.export(), as: .publicKey)` |\n| Secret key | `PGPArmorTypeSecret`  | `Armor.armored(key.export(), as: .secretKey)` |\n\nFor any result of encryption the type is `PGPArmorMessage`\n\n## Changelog\n\nSee [CHANGELOG](./CHANGELOG)\n\nKnown limitations:\n\n- Cleartext signature.\n\n## Security Audit\n\nTo date the ObjectivePGP code base has undergone a complete security audit from [Cure53](https://cure53.de/).\n\n### Acknowledgment\n\nThis product uses software developed by the [OpenSSL](https://www.openssl.org/) Project for use in the OpenSSL Toolkit. (http://www.openssl.org/)\n\n### Author\n\n[Marcin Krzyżanowski](https://krzyzanowskim.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrzyzanowskim%2Fobjectivepgp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrzyzanowskim%2Fobjectivepgp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrzyzanowskim%2Fobjectivepgp/lists"}