inline_encryption 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +77 -0
- data/Guardfile +16 -0
- data/LICENSE.txt +22 -0
- data/README.md +19 -0
- data/Rakefile +6 -0
- data/bin/inline_encryption +6 -0
- data/inline_encryption.gemspec +35 -0
- data/lib/inline_encryption/base.rb +73 -0
- data/lib/inline_encryption/cli.rb +49 -0
- data/lib/inline_encryption/config.rb +38 -0
- data/lib/inline_encryption/errors.rb +7 -0
- data/lib/inline_encryption/version.rb +3 -0
- data/lib/inline_encryption.rb +10 -0
- data/spec/inline_encryption/base_spec.rb +88 -0
- data/spec/inline_encryption/cli_spec.rb +19 -0
- data/spec/inline_encryption/config_spec.rb +58 -0
- data/spec/inline_encryption_spec.rb +13 -0
- data/spec/spec_helper.rb +20 -0
- metadata +221 -0
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
inline_encryption (0.0.6)
|
5
|
+
hashie
|
6
|
+
thor
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
childprocess (0.3.9)
|
12
|
+
ffi (~> 1.0, >= 1.0.11)
|
13
|
+
coderay (1.0.9)
|
14
|
+
diff-lcs (1.2.4)
|
15
|
+
ffi (1.8.1)
|
16
|
+
formatador (0.2.4)
|
17
|
+
guard (1.8.0)
|
18
|
+
formatador (>= 0.2.4)
|
19
|
+
listen (>= 1.0.0)
|
20
|
+
lumberjack (>= 1.0.2)
|
21
|
+
pry (>= 0.9.10)
|
22
|
+
thor (>= 0.14.6)
|
23
|
+
guard-rspec (3.0.1)
|
24
|
+
guard (>= 1.8)
|
25
|
+
rspec (~> 2.13)
|
26
|
+
guard-spork (1.5.0)
|
27
|
+
childprocess (>= 0.2.3)
|
28
|
+
guard (>= 1.1)
|
29
|
+
spork (>= 0.8.4)
|
30
|
+
hashie (2.0.5)
|
31
|
+
listen (1.1.5)
|
32
|
+
rb-fsevent (>= 0.9.3)
|
33
|
+
rb-inotify (>= 0.9)
|
34
|
+
rb-kqueue (>= 0.2)
|
35
|
+
lumberjack (1.0.3)
|
36
|
+
method_source (0.8.1)
|
37
|
+
multi_json (1.7.7)
|
38
|
+
pry (0.9.12.2)
|
39
|
+
coderay (~> 1.0.5)
|
40
|
+
method_source (~> 0.8)
|
41
|
+
slop (~> 3.4)
|
42
|
+
rake (10.1.0)
|
43
|
+
rb-fsevent (0.9.3)
|
44
|
+
rb-inotify (0.9.0)
|
45
|
+
ffi (>= 0.5.0)
|
46
|
+
rb-kqueue (0.2.0)
|
47
|
+
ffi (>= 0.5.0)
|
48
|
+
rspec (2.13.0)
|
49
|
+
rspec-core (~> 2.13.0)
|
50
|
+
rspec-expectations (~> 2.13.0)
|
51
|
+
rspec-mocks (~> 2.13.0)
|
52
|
+
rspec-core (2.13.1)
|
53
|
+
rspec-expectations (2.13.0)
|
54
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
55
|
+
rspec-mocks (2.13.1)
|
56
|
+
simplecov (0.7.1)
|
57
|
+
multi_json (~> 1.0)
|
58
|
+
simplecov-html (~> 0.7.1)
|
59
|
+
simplecov-html (0.7.1)
|
60
|
+
slop (3.4.5)
|
61
|
+
spork (0.9.2)
|
62
|
+
thor (0.18.1)
|
63
|
+
yard (0.8.6.1)
|
64
|
+
|
65
|
+
PLATFORMS
|
66
|
+
ruby
|
67
|
+
|
68
|
+
DEPENDENCIES
|
69
|
+
bundler (~> 1.3)
|
70
|
+
guard
|
71
|
+
guard-rspec
|
72
|
+
guard-spork
|
73
|
+
inline_encryption!
|
74
|
+
rake
|
75
|
+
rspec
|
76
|
+
simplecov
|
77
|
+
yard
|
data/Guardfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'rspec', :all_after_pass => true, :focus_on_failed => true, :all_on_start => true, :cli => "--drb" do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)\.rb$}){ |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb'){ "spec" }
|
8
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
9
|
+
end
|
10
|
+
|
11
|
+
guard 'spork', :test_unit => false do
|
12
|
+
watch('Gemfile')
|
13
|
+
watch('Gemfile.lock')
|
14
|
+
watch('spec/spec_helper.rb') { :rspec }
|
15
|
+
end
|
16
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Bryan Taylor
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# inline_encryption [![Build Status](https://travis-ci.org/rubyisbeautiful/inline_encryption.png)](https://travis-ci.org/rubyisbeautiful/inline_encryption)
|
2
|
+
|
3
|
+
Simple encryption relying on convention and designed to be used inline as string replacements.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
Imagine you have a file named `database.yml` that contains passwords.
|
8
|
+
|
9
|
+
Before:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
password: '123456'
|
13
|
+
```
|
14
|
+
|
15
|
+
After:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
password: <%= InlineEncryption.decrypt(encrypted stuff goes here) %>
|
19
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'base64'
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'inline_encryption/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "inline_encryption"
|
9
|
+
spec.version = InlineEncryption::VERSION
|
10
|
+
spec.authors = ["Bryan Taylor"]
|
11
|
+
spec.email = ['YmNwdGF5bG9yQGdtYWlsLmNvbQ==\n'].collect{ |foo| Base64.decode64(foo) }
|
12
|
+
spec.description = %q{ A simple encryption tool based on common convention }
|
13
|
+
spec.summary = %q{ A simple encryption tool based on common convention and designed as a drop in for Stringish things }
|
14
|
+
spec.homepage = "http://github.com/rubyisbeautiful/inline_encryption"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
spec.required_ruby_version = '>= 1.9.3'
|
22
|
+
|
23
|
+
spec.executables = ['inline_encryption']
|
24
|
+
|
25
|
+
spec.add_runtime_dependency 'hashie'
|
26
|
+
spec.add_runtime_dependency 'thor'
|
27
|
+
|
28
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
29
|
+
spec.add_development_dependency "guard"
|
30
|
+
spec.add_development_dependency "guard-rspec"
|
31
|
+
spec.add_development_dependency "guard-spork"
|
32
|
+
spec.add_development_dependency "rake"
|
33
|
+
spec.add_development_dependency "rspec"
|
34
|
+
spec.add_development_dependency "yard"
|
35
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module InlineEncryption
|
2
|
+
|
3
|
+
module Base
|
4
|
+
|
5
|
+
|
6
|
+
# @param [String] data encryption target
|
7
|
+
# @return [String] encrypted target
|
8
|
+
# @raise [EncryptionFailureError] couldn't encrypt the target
|
9
|
+
def encrypt!(data)
|
10
|
+
config.check_required_variables
|
11
|
+
|
12
|
+
begin
|
13
|
+
encrypted = config.real_key.private_encrypt(data)
|
14
|
+
converted = Base64.encode64(encrypted)
|
15
|
+
rescue => e
|
16
|
+
err = EncryptionFailureError.exception "Target: #{data}"
|
17
|
+
raise err
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
# @param [String] encryption target
|
23
|
+
# @return [String] encrypted target, or fail_text on error (default data)
|
24
|
+
def encrypt(data, fail_text=nil)
|
25
|
+
config.check_required_variables
|
26
|
+
|
27
|
+
begin
|
28
|
+
encrypt!(data)
|
29
|
+
rescue EncryptionFailureError => e
|
30
|
+
return fail_text.nil? ? data : fail_text.to_s
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
# @param [String] data decryption target
|
36
|
+
# @return [String] decrypted target
|
37
|
+
# @raise [DecryptionFailureError] couldn't decrypt the target
|
38
|
+
def decrypt!(data)
|
39
|
+
config.check_required_variables
|
40
|
+
|
41
|
+
begin
|
42
|
+
converted = Base64.decode64(data)
|
43
|
+
this_key = config.real_key.private? ? config.real_key.public_key : config.real_key
|
44
|
+
decrypted = this_key.public_decrypt(converted)
|
45
|
+
rescue => e
|
46
|
+
err = DecryptionFailureError.exception "Encrypted: #{data}"
|
47
|
+
raise err
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
# @param [String] decryption target
|
53
|
+
# @param [String] text to be returned in the case of a decryption failure
|
54
|
+
# @return [String] decrypted target
|
55
|
+
def decrypt(data, fail_text=nil)
|
56
|
+
config.check_required_variables
|
57
|
+
|
58
|
+
begin
|
59
|
+
decrypt!(data)
|
60
|
+
rescue DecryptionFailureError => e
|
61
|
+
return fail_text.nil? ? data : fail_text.to_s
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
# @return [InlineEncryption::Config] the configuration instance
|
67
|
+
def config
|
68
|
+
@config ||= Config.new
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module InlineEncryption
|
4
|
+
|
5
|
+
class CLI < Thor
|
6
|
+
|
7
|
+
class_option :config, :aliases => ["-c"], :type => :string
|
8
|
+
|
9
|
+
def initialize(args=[], opts=[], config={})
|
10
|
+
super(args, opts, config)
|
11
|
+
|
12
|
+
if options[:config] && File.exists?(options[:config])
|
13
|
+
@options = YAML.load_file(options[:config]).symbolize_keys.merge(@options.symbolize_keys)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
desc "encrypt [DATA]", "encrypt stuff"
|
19
|
+
class_option :require, :aliases => ["-r"], :type => :string
|
20
|
+
def encrypt(data)
|
21
|
+
#puts options
|
22
|
+
load_enviroment(options[:require])
|
23
|
+
|
24
|
+
puts InlineEncryption.encrypt(data)
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
protected
|
30
|
+
|
31
|
+
|
32
|
+
def load_enviroment(file=nil)
|
33
|
+
file ||= "."
|
34
|
+
|
35
|
+
if File.directory?(file) && File.exists?(File.expand_path("#{file}/config/environment.rb"))
|
36
|
+
require "rails"
|
37
|
+
require File.expand_path("#{file}/config/environment.rb")
|
38
|
+
if defined?(::Rails) && ::Rails.respond_to?(:application)
|
39
|
+
# Rails 3
|
40
|
+
# ::Rails.application.eager_load!
|
41
|
+
end
|
42
|
+
elsif File.file?(file)
|
43
|
+
require File.expand_path(file)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'hashie/extensions/indifferent_access'
|
2
|
+
require 'hashie/extensions/method_access'
|
3
|
+
require 'openssl'
|
4
|
+
|
5
|
+
module InlineEncryption
|
6
|
+
|
7
|
+
# known configuration variables
|
8
|
+
# key - a String containing the private key, a filename pointing to the private key, or an OpenSSL::PKey::RSA
|
9
|
+
class Config < Hash
|
10
|
+
include Hashie::Extensions::IndifferentAccess
|
11
|
+
include Hashie::Extensions::MethodAccess
|
12
|
+
|
13
|
+
# checks required, currently only the 'key'
|
14
|
+
# @raises [InlineEncryption::MissingRequiredVariableError] raise on a missing variable
|
15
|
+
def check_required_variables
|
16
|
+
raise MissingRequiredVariableError.new("missing variable: 'key'") unless self.has_key?(:key)
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
# @return [OpenSSL::PKey::RSA] the OpenSSL key instance
|
21
|
+
def real_key
|
22
|
+
case self[:key]
|
23
|
+
when NilClass
|
24
|
+
nil
|
25
|
+
when String
|
26
|
+
if File.exists?(self[:key])
|
27
|
+
OpenSSL::PKey::RSA.new(File.read(self[:key]))
|
28
|
+
else
|
29
|
+
OpenSSL::PKey::RSA.new(self[:key])
|
30
|
+
end
|
31
|
+
when OpenSSL::PKey::RSA
|
32
|
+
self[:key]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'base64'
|
3
|
+
|
4
|
+
describe InlineEncryption::Base do
|
5
|
+
|
6
|
+
before :all do
|
7
|
+
@default_key = OpenSSL::PKey::RSA.generate(2048)
|
8
|
+
end
|
9
|
+
|
10
|
+
before :each do
|
11
|
+
InlineEncryption.config[:key] = @default_key
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'encrypt' do
|
15
|
+
|
16
|
+
let(:str){ 'foo' }
|
17
|
+
|
18
|
+
it 'should encrypt' do
|
19
|
+
InlineEncryption.encrypt(str).should == Base64.encode64(@default_key.private_encrypt(str))
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should fail to encrpyt and return the target' do
|
23
|
+
InlineEncryption.config[:key] = OpenSSL::PKey::RSA.generate(32)
|
24
|
+
InlineEncryption.encrypt(str*2).should == str*2
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should fail to encrypt and return the fail_text' do
|
28
|
+
InlineEncryption.config[:key] = OpenSSL::PKey::RSA.generate(32)
|
29
|
+
InlineEncryption.encrypt(str*2, 'chunky').should == 'chunky'
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'encrypt!' do
|
35
|
+
let(:str){ 'foo' }
|
36
|
+
|
37
|
+
it 'should encrypt' do
|
38
|
+
InlineEncryption.encrypt!(str).should == Base64.encode64(@default_key.private_encrypt(str))
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should fail to encrpyt and raise' do
|
42
|
+
InlineEncryption.config[:key] = OpenSSL::PKey::RSA.generate(32)
|
43
|
+
expect{ InlineEncryption.encrypt!(str*2) }.to raise_error(InlineEncryption::EncryptionFailureError)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'decrypt' do
|
49
|
+
|
50
|
+
before :all do
|
51
|
+
@str = Base64.encode64(@default_key.private_encrypt('chunky'))
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should decrypt' do
|
55
|
+
InlineEncryption.decrypt(@str).should == 'chunky'
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should fail to decrypt and return the target' do
|
59
|
+
InlineEncryption.config[:key] = OpenSSL::PKey::RSA.generate(32)
|
60
|
+
InlineEncryption.decrypt(@str).should == @str
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should fail to decrypt and return the fail_text' do
|
64
|
+
InlineEncryption.config[:key] = OpenSSL::PKey::RSA.generate(32)
|
65
|
+
InlineEncryption.decrypt(@str, 'chunky').should == 'chunky'
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
describe 'decrypt!' do
|
71
|
+
|
72
|
+
before :all do
|
73
|
+
@str = Base64.encode64(@default_key.private_encrypt('chunky'))
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should decrypt' do
|
77
|
+
InlineEncryption.decrypt!(@str).should == 'chunky'
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should fail to decrpyt and raise' do
|
81
|
+
InlineEncryption.config[:key] = OpenSSL::PKey::RSA.generate(32)
|
82
|
+
expect{ InlineEncryption.decrypt!(@str) }.to raise_error(InlineEncryption::DecryptionFailureError)
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'base64'
|
3
|
+
|
4
|
+
describe InlineEncryption::CLI do
|
5
|
+
|
6
|
+
let(:subject){ InlineEncryption::CLI.new }
|
7
|
+
|
8
|
+
before :all do
|
9
|
+
@default_key = OpenSSL::PKey::RSA.generate(2048)
|
10
|
+
InlineEncryption.config[:key] = @default_key
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should encrypt' do
|
14
|
+
InlineEncryption.should_receive(:encrypt).with('hello')
|
15
|
+
|
16
|
+
subject.encrypt('hello')
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe InlineEncryption::Config do
|
4
|
+
|
5
|
+
describe 'check_required_values' do
|
6
|
+
let(:subject){ InlineEncryption::Config.new }
|
7
|
+
|
8
|
+
it "should raise if 'key' is not set" do
|
9
|
+
expect{ subject.check_required_variables }.to raise_error(InlineEncryption::MissingRequiredVariableError)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should not raise if 'key' is set" do
|
13
|
+
subject[:key] = 'foo'
|
14
|
+
expect{ subject.check_required_variables }.to_not raise_error(InlineEncryption::MissingRequiredVariableError)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
describe 'real_key' do
|
21
|
+
let(:subject){ InlineEncryption::Config.new }
|
22
|
+
|
23
|
+
it 'should return nil if key is NilClass' do
|
24
|
+
subject[:key] = nil
|
25
|
+
|
26
|
+
subject.real_key.should == nil
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should return the key value if key is an OpenSSL::PKey::RSA key' do
|
30
|
+
key = OpenSSL::PKey::RSA.new(128)
|
31
|
+
subject[:key] = key
|
32
|
+
|
33
|
+
subject.real_key.should == key
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should return an OpenSSL::PKey::RSA key from the given String' do
|
37
|
+
temp_key = OpenSSL::PKey::RSA.generate(32)
|
38
|
+
key = temp_key.to_s
|
39
|
+
subject[:key] = key
|
40
|
+
|
41
|
+
subject.real_key.to_s.should == temp_key.to_s
|
42
|
+
subject.real_key.should be_an_instance_of OpenSSL::PKey::RSA
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should load the contents of the given file if exists and use as key' do
|
46
|
+
temp_key = OpenSSL::PKey::RSA.generate(32)
|
47
|
+
key = 'foo'
|
48
|
+
subject[:key] = key
|
49
|
+
File.stub(:exists?).with('foo').and_return(true)
|
50
|
+
File.stub(:read).with('foo').and_return(temp_key.to_s)
|
51
|
+
|
52
|
+
subject.real_key.to_s.should == temp_key.to_s
|
53
|
+
subject.real_key.should be_an_instance_of OpenSSL::PKey::RSA
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe InlineEncryption do
|
4
|
+
|
5
|
+
it 'should load Base' do
|
6
|
+
expect{ InlineEncryption::Base }.not_to raise_error
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should be extended by Base' do
|
10
|
+
InlineEncryption.respond_to?(:config).should be_true
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spork'
|
3
|
+
#uncomment the following line to use spork with the debugger
|
4
|
+
#require 'spork/ext/ruby-debug'
|
5
|
+
|
6
|
+
Spork.prefork do
|
7
|
+
require 'simplecov'
|
8
|
+
SimpleCov.start do
|
9
|
+
add_filter "/spec/"
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'rspec'
|
13
|
+
|
14
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
15
|
+
require 'inline_encryption'
|
16
|
+
end
|
17
|
+
|
18
|
+
Spork.each_run do
|
19
|
+
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,221 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: inline_encryption
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.6
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Bryan Taylor
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-07-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: hashie
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: thor
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: bundler
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.3'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: guard
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: guard-rspec
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: guard-spork
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: rake
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: rspec
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: yard
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
description: ! ' A simple encryption tool based on common convention '
|
159
|
+
email:
|
160
|
+
- !binary |-
|
161
|
+
YmNwdGF5bG9yQGdtYWlsLmNvbQ==
|
162
|
+
executables:
|
163
|
+
- inline_encryption
|
164
|
+
extensions: []
|
165
|
+
extra_rdoc_files: []
|
166
|
+
files:
|
167
|
+
- .gitignore
|
168
|
+
- .rspec
|
169
|
+
- .travis.yml
|
170
|
+
- Gemfile
|
171
|
+
- Gemfile.lock
|
172
|
+
- Guardfile
|
173
|
+
- LICENSE.txt
|
174
|
+
- README.md
|
175
|
+
- Rakefile
|
176
|
+
- bin/inline_encryption
|
177
|
+
- inline_encryption.gemspec
|
178
|
+
- lib/inline_encryption.rb
|
179
|
+
- lib/inline_encryption/base.rb
|
180
|
+
- lib/inline_encryption/cli.rb
|
181
|
+
- lib/inline_encryption/config.rb
|
182
|
+
- lib/inline_encryption/errors.rb
|
183
|
+
- lib/inline_encryption/version.rb
|
184
|
+
- spec/inline_encryption/base_spec.rb
|
185
|
+
- spec/inline_encryption/cli_spec.rb
|
186
|
+
- spec/inline_encryption/config_spec.rb
|
187
|
+
- spec/inline_encryption_spec.rb
|
188
|
+
- spec/spec_helper.rb
|
189
|
+
homepage: http://github.com/rubyisbeautiful/inline_encryption
|
190
|
+
licenses:
|
191
|
+
- MIT
|
192
|
+
post_install_message:
|
193
|
+
rdoc_options: []
|
194
|
+
require_paths:
|
195
|
+
- lib
|
196
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
197
|
+
none: false
|
198
|
+
requirements:
|
199
|
+
- - ! '>='
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: 1.9.3
|
202
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
203
|
+
none: false
|
204
|
+
requirements:
|
205
|
+
- - ! '>='
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: '0'
|
208
|
+
requirements: []
|
209
|
+
rubyforge_project:
|
210
|
+
rubygems_version: 1.8.23
|
211
|
+
signing_key:
|
212
|
+
specification_version: 3
|
213
|
+
summary: A simple encryption tool based on common convention and designed as a drop
|
214
|
+
in for Stringish things
|
215
|
+
test_files:
|
216
|
+
- spec/inline_encryption/base_spec.rb
|
217
|
+
- spec/inline_encryption/cli_spec.rb
|
218
|
+
- spec/inline_encryption/config_spec.rb
|
219
|
+
- spec/inline_encryption_spec.rb
|
220
|
+
- spec/spec_helper.rb
|
221
|
+
has_rdoc:
|