conceal 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4a702eefd1ed82b3c014f4b89edaf6ca14e30242
4
+ data.tar.gz: da0bb21cc6c2c856646546971c9f41ee35179f53
5
+ SHA512:
6
+ metadata.gz: ff85d8c71613582a185520487e16776c1c7a400140ee0d8a6053b3cd6355b2f86e9f99818b2a56356a82d11c4d575a601dfbc7cb8f8d944d49a8120ed816f781
7
+ data.tar.gz: 1d178801b039dbb3aee4bd004c820659ddf135ef6362f19a17edd3a7f7514c07da0a43d5b9171f50a5861cf3628edd7d278e9efc08c6561a3a243f464833acd9
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0
4
+
5
+ * Backwards incompatible changes
6
+ * Merged `decrypt` and `encrypt` commands into a single binary: `conceal decrypt` and `conceal encrypt`.
7
+
8
+ ## 0.1.0
9
+
10
+ * Initial release
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # Conceal
2
2
 
3
- Simple OpenSSL-based string encryption using a shared secret. The algorithm, initialization vector, salt, crypttext, and HMAC are all encoded into a single string
4
- so it is easy to copy around.
3
+ Simple OpenSSL-based string encryption using a shared secret. The algorithm, initialization vector, salt, crypttext, and HMAC are all encoded into a single string so it is easy to copy around.
5
4
 
6
5
  ## Requirements
7
6
 
@@ -11,23 +10,40 @@ so it is easy to copy around.
11
10
 
12
11
  Add this line to your application's Gemfile:
13
12
 
14
- gem 'conceal'
13
+ ```ruby
14
+ gem 'conceal'
15
+ ```
15
16
 
16
17
  And then execute:
17
18
 
18
- $ bundle
19
+ ```
20
+ $ bundle
21
+ ```
19
22
 
20
23
  Or install it yourself as:
21
24
 
22
- $ gem install conceal
25
+ ```
26
+ $ gem install conceal
27
+ ```
23
28
 
24
29
  ## Usage
25
30
 
31
+ This gem provides both a ruby library and some command-line utilities.
32
+
33
+ ### Library
34
+
26
35
  ```ruby
27
36
  encrypted = Conceal.encrypt('some plaintext', key: 'your shared secret', algorithm: 'aes-256-cbc')
28
37
  decrypted = Conceal.decrypt(encrypted, key: 'your shared secret')
29
38
  ```
30
39
 
40
+ ### Command-line
41
+
42
+ ```
43
+ $ ruby -rsecurerandom -e 'print SecureRandom.urlsafe_base64(32)' | conceal encrypt key.file | pbcopy
44
+ $ pbpaste | conceal decrypt key.file | pbcopy
45
+ ```
46
+
31
47
  ## Authors
32
48
 
33
49
  * Ben Scott (<gamepoet@gmail.com>)
data/bin/conceal ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ lib = File.expand_path('../../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'conceal/cli'
5
+ Conceal::CLI.start(ARGV)
data/conceal.gemspec CHANGED
@@ -20,6 +20,8 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.required_ruby_version = '>= 1.9.3'
22
22
 
23
+ spec.add_dependency 'thor', '~> 0.18'
24
+
23
25
  spec.add_development_dependency 'bundler', '~> 1.6'
24
26
  spec.add_development_dependency 'rake', '>= 0.8.7'
25
27
  spec.add_development_dependency 'rspec', '~> 3.0'
@@ -0,0 +1,54 @@
1
+ require 'thor'
2
+
3
+ module Conceal
4
+ class CLI < Thor
5
+ map %w(d de dec) => :decrypt
6
+ map %w(e en enc) => :encrypt
7
+ map %w(-v --version) => :version
8
+
9
+ option :newline, aliases: '-n', type: :boolean, desc: 'print a trailing newline character'
10
+ desc 'decrypt [OPTIONS] KEY_FILE', 'decrypt stdin using the given key file'
11
+ def decrypt(key_file)
12
+ require 'conceal'
13
+
14
+ # load the key
15
+ raise Thor::Error, 'ERROR: key file is not readable or does not exist' unless File.readable?(key_file)
16
+ key = IO.read(key_file)
17
+
18
+ # decrypt from stdin
19
+ encrypted_data = $stdin.read
20
+ plaintext = Conceal.decrypt(encrypted_data, key: key)
21
+
22
+ $stdout.write(plaintext)
23
+ $stdout.write("\n") if options[:newline]
24
+ end
25
+
26
+ option :newline, aliases: '-n', type: :boolean, desc: 'print a trailing newline character'
27
+ desc 'encrypt [OPTIONS] KEY_FILE', 'encrypt stdin using the given key file'
28
+ def encrypt(key_file)
29
+ require 'conceal'
30
+
31
+ # load the key
32
+ raise Thor::Error, 'ERROR: key file is not readable or does not exist' unless File.readable?(key_file)
33
+ key = IO.read(key_file)
34
+
35
+ # encrypt from stdin
36
+ plaintext = $stdin.read
37
+ encrypted_data = Conceal.encrypt(plaintext, key: key)
38
+
39
+ $stdout.write(encrypted_data)
40
+ $stdout.write("\n") if options[:newline]
41
+ end
42
+
43
+ desc 'version', 'display the version and exit'
44
+ def version
45
+ require 'conceal/version'
46
+ puts VERSION
47
+ end
48
+
49
+ protected
50
+ def self.exit_on_failure?
51
+ true
52
+ end
53
+ end
54
+ end
@@ -1,3 +1,3 @@
1
1
  module Conceal
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,115 +1,119 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conceal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ben Scott
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-08-26 00:00:00.000000000 Z
11
+ date: 2014-09-05 00:00:00.000000000 Z
13
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.18'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.18'
14
27
  - !ruby/object:Gem::Dependency
15
28
  name: bundler
16
29
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
30
  requirements:
19
- - - ~>
31
+ - - "~>"
20
32
  - !ruby/object:Gem::Version
21
33
  version: '1.6'
22
34
  type: :development
23
35
  prerelease: false
24
36
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
37
  requirements:
27
- - - ~>
38
+ - - "~>"
28
39
  - !ruby/object:Gem::Version
29
40
  version: '1.6'
30
41
  - !ruby/object:Gem::Dependency
31
42
  name: rake
32
43
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
44
  requirements:
35
- - - ! '>='
45
+ - - ">="
36
46
  - !ruby/object:Gem::Version
37
47
  version: 0.8.7
38
48
  type: :development
39
49
  prerelease: false
40
50
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
51
  requirements:
43
- - - ! '>='
52
+ - - ">="
44
53
  - !ruby/object:Gem::Version
45
54
  version: 0.8.7
46
55
  - !ruby/object:Gem::Dependency
47
56
  name: rspec
48
57
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
58
  requirements:
51
- - - ~>
59
+ - - "~>"
52
60
  - !ruby/object:Gem::Version
53
61
  version: '3.0'
54
62
  type: :development
55
63
  prerelease: false
56
64
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
65
  requirements:
59
- - - ~>
66
+ - - "~>"
60
67
  - !ruby/object:Gem::Version
61
68
  version: '3.0'
62
69
  description: Encrypts and decrypts strings using OpenSSL.
63
70
  email:
64
71
  - gamepoet@gmail.com
65
72
  executables:
66
- - decrypt
67
- - encrypt
73
+ - conceal
68
74
  extensions: []
69
75
  extra_rdoc_files: []
70
76
  files:
71
- - .gitignore
72
- - .rspec
73
- - .travis.yml
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - CHANGELOG.md
74
81
  - Gemfile
75
82
  - LICENSE
76
83
  - README.md
77
84
  - Rakefile
78
- - bin/decrypt
79
- - bin/encrypt
85
+ - bin/conceal
80
86
  - conceal.gemspec
81
87
  - lib/conceal.rb
88
+ - lib/conceal/cli.rb
82
89
  - lib/conceal/version.rb
83
90
  - spec/conceal_spec.rb
84
91
  - spec/spec_helper.rb
85
92
  homepage: https://github.com/gamepoet/conceal
86
93
  licenses:
87
94
  - MIT
95
+ metadata: {}
88
96
  post_install_message:
89
97
  rdoc_options: []
90
98
  require_paths:
91
99
  - lib
92
100
  required_ruby_version: !ruby/object:Gem::Requirement
93
- none: false
94
101
  requirements:
95
- - - ! '>='
102
+ - - ">="
96
103
  - !ruby/object:Gem::Version
97
104
  version: 1.9.3
98
105
  required_rubygems_version: !ruby/object:Gem::Requirement
99
- none: false
100
106
  requirements:
101
- - - ! '>='
107
+ - - ">="
102
108
  - !ruby/object:Gem::Version
103
109
  version: '0'
104
- segments:
105
- - 0
106
- hash: 3065879142632505148
107
110
  requirements: []
108
111
  rubyforge_project:
109
- rubygems_version: 1.8.23.2
112
+ rubygems_version: 2.2.2
110
113
  signing_key:
111
- specification_version: 3
114
+ specification_version: 4
112
115
  summary: Simple OpenSSL-based string encryption.
113
116
  test_files:
114
117
  - spec/conceal_spec.rb
115
118
  - spec/spec_helper.rb
119
+ has_rdoc:
data/bin/decrypt DELETED
@@ -1,42 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'conceal'
3
- require 'optparse'
4
-
5
- class Options < Struct.new(:trailing_newline)
6
- end
7
-
8
- def main
9
- opts = Options.new
10
- opts.trailing_newline = true
11
-
12
- OptionParser.new do |o|
13
- o.banner = 'Usage: decrypt KEY_FILE'
14
- o.on('-h', '--help', 'show this message') do
15
- puts o
16
- exit(0)
17
- end
18
- o.on('-n', "don't print the trailing newline") do
19
- opts.trailing_newline = false
20
- end
21
- o.on('-v', '--version', 'print the version') do
22
- puts Conceal::VERSION
23
- end
24
- end.parse!(ARGV)
25
-
26
- # read the key file
27
- if ARGV.empty?
28
- $stderr.puts "Missing KEY_FILE argument"
29
- exit(1)
30
- end
31
- key_file = ARGV.shift
32
- key = IO.read(key_file)
33
-
34
- # decrypt from stdin
35
- encrypted_data = $stdin.read
36
- plaintext = Conceal.decrypt(encrypted_data, key: key)
37
-
38
- $stdout.write(plaintext)
39
- $stdout.write("\n") if opts.trailing_newline
40
- end
41
-
42
- main
data/bin/encrypt DELETED
@@ -1,42 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'conceal'
3
- require 'optparse'
4
-
5
- class Options < Struct.new(:trailing_newline)
6
- end
7
-
8
- def main
9
- opts = Options.new
10
- opts.trailing_newline = true
11
-
12
- OptionParser.new do |o|
13
- o.banner = 'Usage: encrypt KEY_FILE'
14
- o.on('-h', '--help', 'show this message') do
15
- puts o
16
- exit(0)
17
- end
18
- o.on('-n', "don't print the trailing newline") do
19
- opts.trailing_newline = false
20
- end
21
- o.on('-v', '--version', 'print the version') do
22
- puts Conceal::VERSION
23
- end
24
- end.parse!(ARGV)
25
-
26
- # read the key file
27
- if ARGV.empty?
28
- $stderr.puts "Missing KEY_FILE argument"
29
- exit(1)
30
- end
31
- key_file = ARGV.shift
32
- key = IO.read(key_file)
33
-
34
- # encrypt from stdin
35
- plaintext = $stdin.read
36
- encrypted_data = Conceal.encrypt(plaintext, key: key)
37
-
38
- $stdout.write(encrypted_data)
39
- $stdout.write("\n") if opts.trailing_newline
40
- end
41
-
42
- main