Giter Club home page Giter Club logo

exgpg's Introduction

Exgpg

Use gpg from elixir

Installation

Add this to your mixfile

 { :exgpg, "~> 0.0.3" },

Install goon and put it on your PATH. If you can run goon and get a usage output, then porcelain and thereby exgpg will be able to use it.

Usage

Symmetric

#proc is a Porcelain.Process. The `out` key is a stream of gpg's output.
proc = Exgpg.symmetric("test string", [passphrase: "hunter2"])

# this will be a binary of the encrypted "test string"
encrypted = Enum.into(proc.out, "") 

proc = Exgpg.decrypt(encrypted, [passphrase: "hunter2"])

#put the decrypt stream into a string
Enum.into(proc.out, "") # this will be "test string"

Asymmetric

#proc is a Porcelain.Process. The `out` key is a stream of gpg's output. this
#method allows for direct piping..
defp output(proc), do: proc.out

out = "hello world"
|> Exgpg.encrypt([{:recipient, "[email protected]"}, {keyring: "alice.pub"}])
|> output
|> Exgpg.decrypt([secret_keyring: "alice.sec", keyring: "alice.pub"])
|> output
|> Enum.into("")

IO.puts out # this will print "hello world"

Generate a keypair

{:ok, proc} = Exgpg.gen_key(
      [
        key_type: "DSA",
        key_length: "1024",
        subkey_type: "ELG-E",
        subkey_length: "1024",
        name_real: "alice",
        name_email: "[email protected]",
        expire_date: "0",
        ctrl_pubring: "alice.pub", #pub ring will be written to alice.pub
        ctrl_secring: "alice.sec", #sec ring will be written to alice.sec
        ctrl_commit: "",
        ctrl_echo: "done"
      ]
    )

proc.status #will give the status code
proc.err #will give an error description, if one occurred

Options are passed directly to gpg, with a transformation to change the the key_with_underscore keylist convention in elixir to the --key-with-dashes. Most options should Just Work™.

exgpg's People

Contributors

rozap avatar lowks avatar zjvandeweg avatar

Watchers

James Cloos avatar Angel Jose 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.