Code Monkey home page Code Monkey logo

unnetpgp's Introduction

UNNetPGP is Objective-C wrapper for NetPGP for iOS.

About

The PGP solution you've been looking for is here. Low level C based api with Objective-C wrapper around it is all you need to encrypt and decrypt PGP messages. Based on NetPGP, a standards-compliant library and suite of utilities providing digital signature and verification functionality, as well as data encryption and decryption, using RSA and DSA/Elgamal keys.

Known Issues

Due to an unsolved crash when using the SHA-256 algorithm, this library currently uses the SHA-1 hash, which is known to be weak. Patches to fix the crash would be greatly appreciated!

Installation

This package is intended to be used with CocoaPods to satisfy OpenSSL dependency.

Add this to you Podfile:

pod 'UNNetPGP', :podspec => 'https://raw.github.com/krzyzanowskim/unnetpgp/master/UNNetPGP.podspec'
  • Without CocoaPods

Something with Source Trees should do the trick but haven't tested. Pull request welcome.

Usage

Initialize and setup

UNNetPGP *pgp = [[UNNetPGP alloc] initWithUserId:@"[email protected]"];
pgp.password = @"secret1234";
pgp.armored  = YES

Optionally you can specify ringfiles out of home directory

pgp.publicKeyRingPath = [[self documentsDirectory] stringByAppendingPathComponent:@"pubring.gpg"];
pgp.secretKeyRingPath = [[self documentsDirectory] stringByAppendingPathComponent:@"secring.gpg"];

Lets define filenames. Caution: file extension is important for some files! (.gpg,.asc)

NSString *plaintextFile = [myDir stringByAppendingPathComponent:@"plain.txt"];
NSString *encryptedFile = [myDir stringByAppendingPathComponent:@"plain.txt.gpg"];
NSString *decryptedFile = [myDir stringByAppendingPathComponent:@"plain.decoded.txt"];
NSString *signatureFile = [myDir stringByAppendingPathComponent:@"plain.txt.asc"];

Encrypt file

BOOL result = [pgp encryptFileAtPath:plainFilePath toFileAtPath:encryptedFilePath options:UNEncryptOptionNone];
NSLog(@"encryptedFilePath = %@",@(result));

Decrypt file

BOOL result = [pgp decryptFileAtPath:encryptedFilePath toFileAtPath:decryptedFilePath];
NSLog(@"decryptFileAtPath = %@",@(result));

Generate new key (and save in keyring)

BOOL success = [pgp generateKey:1024];

Create file signature

BOOL success = [pgp signFileAtPath:plaintextFile writeToFile:signatureFile detached:YES];

Verify file signature. Caution: there is assumption that signed file exists in the same directory.

BOOL success = [pgp verifyFileAtPath:signatureFile];

Authors

Marcin Krzyżanowski

unnetpgp's People

Contributors

krzyzanowskim avatar tomwhipple avatar hohl avatar pnc avatar readmecritic avatar

Stargazers

 avatar Denis Aleksandrov avatar Igniz avatar Nur Sarowar avatar Jaschar Jisreel Domann avatar Ekko avatar Erik van der Wal avatar Alex avatar Nathan Lewis avatar James Sadler avatar Vitalii Kuznetsov avatar Ulf Buermeyer avatar Devin Egan avatar  avatar Rhett Sutphin avatar Mike English avatar Ross Nelson avatar Vinnie Vendemia avatar Tim Kersey avatar Alaric Cole avatar Blake Jakopovic avatar Kyle Howells avatar Konstantin Stoldt avatar Thomas Myrden avatar  avatar Taras Kalapun avatar Mark Meyer avatar Ashley Connor avatar Colin Young avatar Paul Magrath avatar Pieter Ennes avatar Ethan Kravitz avatar Boris Bügling avatar Felix avatar Blake Watters avatar Sijawusz Pur Rahnama avatar Nbosa avatar Marcus Ficner avatar Roman avatar Zadorozhnyj Dmitrij avatar Chris Ballinger avatar Alax Villmann avatar Vlada Calic avatar Kaya Büyükçelen avatar Terry Horner avatar Cezar Cocu avatar Fabien Penso avatar Lukasz Warchol avatar Aleksander Popek avatar Łukasz Przytuła avatar ‮rekcäH nitraM‮ avatar James Moore avatar  avatar Lars avatar Ben Collins avatar Stuart Macgregor avatar  avatar Yuri Tománek avatar G_will avatar J-P Teti avatar  avatar Vebjorn Ljosa avatar Dominik Wei-Fieg avatar Ian Bernardo avatar  avatar Renée Köcher avatar  avatar

Watchers

Philipp Nowakowski avatar Artur Wdowiarski avatar Sean Voss avatar Leandro Nalio avatar Chris Ballinger avatar  avatar James Cloos avatar Eduard Mossinkoff avatar  avatar David V avatar  avatar  avatar  avatar  avatar Lukasz Warchol avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.