Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rozap/exgpg
gpg interface
https://github.com/rozap/exgpg
Last synced: 8 days ago
JSON representation
gpg interface
- Host: GitHub
- URL: https://github.com/rozap/exgpg
- Owner: rozap
- License: mit
- Created: 2015-01-22T02:27:41.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2018-08-29T22:26:06.000Z (about 6 years ago)
- Last Synced: 2024-08-02T02:11:34.881Z (3 months ago)
- Language: Elixir
- Homepage:
- Size: 256 KB
- Stars: 18
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - Use gpg from Elixir. (Cryptography)
- fucking-awesome-elixir - exgpg - Use gpg from Elixir. (Cryptography)
- awesome-elixir - exgpg - Use gpg from Elixir. (Cryptography)
README
Exgpg
=====Use gpg from elixir
## Installation
Add this to your mixfile
```elixir
{ :exgpg, "~> 0.0.3" },
```Install [goon](https://github.com/alco/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
```elixir
#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
```elixir#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.outout = "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
```elixir
{: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™.