Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial checkin

  • Loading branch information...
commit 20575bf23cd1f8f36c39c96680c990e6a04a7868 0 parents
@demonbane authored
Showing with 98 additions and 0 deletions.
  1. +25 −0 README.md
  2. +3 −0  TODO
  3. +5 −0 bin/pipefish
  4. +65 −0 lib/pipefish.rb
25 README.md
@@ -0,0 +1,25 @@
+Pipefish
+========
+
+Simple in-line encryption/decryption using a Blowfish cipher.
+
+Usage
+-----
+
+```bash
+$ echo "this is my text" | pipefish -k somekey
+<encrypted output>
+$ echo <encrypted output> | pipefish -k somekey -d
+this is my text
+$
+```
+
+Why would I use this?
+---------------------
+
+I specifically wrote this to be able to share semi-sensitive information easily with other folks using gist as the transport mechanism. So something like this:
+
+```bash
+$ echo "my secret stuff" | pipefish -k somekey | gist
+$ curl <raw file url> | pipefish -k somekey -d
+```
3  TODO
@@ -0,0 +1,3 @@
+* use bcrypt or something similar to hash the key to intentionally slow down decryption
+* some sort of checksum to determine whether the decryption actually succeeded or not
+* get someone who actually understands this stuff to verify if it's good or not :)
5 bin/pipefish
@@ -0,0 +1,5 @@
+#!/usr/bin/env ruby
+
+require 'lib/pipefish'
+
+Pipefish.execute(*ARGV)
65 lib/pipefish.rb
@@ -0,0 +1,65 @@
+require 'rubygems'
+require 'crypt/blowfish'
+require 'base64'
+require 'optparse'
+
+module Pipefish
+ Version = "0.1.0"
+
+ extend self
+
+ @config = {}
+ @action = :encrypt
+
+ def execute(*args)
+ opts = OptionParser.new do |opts|
+ opts.banner = "Usage: pipefish [options]"
+
+ opts.on('-k', '--key KEY', 'Specify passkey to use') do |enkey|
+ @config[:enkey] = enkey
+ end
+
+ opts.on('-d', '--decrypt', 'Decrypt input') do |priv|
+ @action = :decrypt
+ end
+
+ opts.on('-e', '--encrypt', 'Encrypt input (default)') do |priv|
+ @action = :encrypt
+ end
+
+ opts.on('-v', '--version', 'Print version') do
+ puts Pipefish::Version
+ exit
+ end
+
+ opts.on('-h', '--help', 'Display this screen') do
+ puts opts
+ exit
+ end
+ end
+
+ opts.parse!(args)
+
+ send(@action)
+ exit
+ end
+
+ def blowfish
+ abort "No passkey provided, exiting." unless key && !key.empty?
+ Crypt::Blowfish.new(key)
+ end
+
+ def key
+ @config[:enkey] || ENV['PIPEFISH_ENKEY']
+ end
+
+ def encrypt
+ payload = Base64.encode64(STDIN.read)
+ puts Base64.encode64(blowfish.encrypt_string(payload))
+ end
+
+ def decrypt
+ payload = Base64.decode64(STDIN.read)
+ puts Base64.decode64(blowfish.decrypt_string(payload))
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.