eggs 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +19 -0
- data/Gemfile.lock +101 -0
- data/LICENSE.txt +20 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +78 -0
- data/Rakefile +40 -0
- data/VERSION +1 -0
- data/eggs.gemspec +56 -0
- data/features/eggs.feature +9 -0
- data/features/step_definitions/eggs_steps.rb +0 -0
- data/features/support/env.rb +13 -0
- data/lib/eggs.rb +61 -0
- data/spec/eggs_spec.rb +56 -0
- data/spec/spec_helper.rb +12 -0
- metadata +76 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 085f40b13d50a2eaec1acb87831d61611b1ebeab
|
4
|
+
data.tar.gz: 158d15e961fced6b4710a4a6a996af5eeb2c0d7c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 11d2dd008bbad19653aa7f429bbecf49abaac2dab88b777a02a0f3f6621ef5c6647fe4cbd12486b9d1887450dd0f03c306e44a3d929e9b9c65a0f4b433e030ba
|
7
|
+
data.tar.gz: 463b23b473cded1efb2ef17b3fbae883e07361b62a33b8efed4274ce3e580dbccdea38200309b3c5373a19e3d1360f76e1201fa97338b45845dfa4a162737a63
|
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
gem "activesupport"
|
6
|
+
|
7
|
+
|
8
|
+
# Add dependencies to develop your gem here.
|
9
|
+
# Include everything needed to run rake, tests, features, etc.
|
10
|
+
group :test do
|
11
|
+
gem "rspec", "~> 2.8.0"
|
12
|
+
gem "yard", "~> 0.7"
|
13
|
+
gem "rdoc", "~> 3.12"
|
14
|
+
gem "cucumber", ">= 0"
|
15
|
+
gem "bundler", "~> 1.0"
|
16
|
+
gem "jeweler", "~> 1.8.7"
|
17
|
+
gem "simplecov", :require => false # https://github.com/colszowka/simplecov
|
18
|
+
gem "pry"
|
19
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (4.0.1)
|
5
|
+
i18n (~> 0.6, >= 0.6.4)
|
6
|
+
minitest (~> 4.2)
|
7
|
+
multi_json (~> 1.3)
|
8
|
+
thread_safe (~> 0.1)
|
9
|
+
tzinfo (~> 0.3.37)
|
10
|
+
addressable (2.3.5)
|
11
|
+
atomic (1.1.14)
|
12
|
+
builder (3.2.2)
|
13
|
+
coderay (1.0.9)
|
14
|
+
cucumber (1.3.8)
|
15
|
+
builder (>= 2.1.2)
|
16
|
+
diff-lcs (>= 1.1.3)
|
17
|
+
gherkin (~> 2.12.1)
|
18
|
+
multi_json (>= 1.7.5, < 2.0)
|
19
|
+
multi_test (>= 0.0.2)
|
20
|
+
diff-lcs (1.1.3)
|
21
|
+
faraday (0.8.8)
|
22
|
+
multipart-post (~> 1.2.0)
|
23
|
+
gherkin (2.12.2)
|
24
|
+
multi_json (~> 1.3)
|
25
|
+
git (1.2.6)
|
26
|
+
github_api (0.10.1)
|
27
|
+
addressable
|
28
|
+
faraday (~> 0.8.1)
|
29
|
+
hashie (>= 1.2)
|
30
|
+
multi_json (~> 1.4)
|
31
|
+
nokogiri (~> 1.5.2)
|
32
|
+
oauth2
|
33
|
+
hashie (2.0.5)
|
34
|
+
highline (1.6.20)
|
35
|
+
httpauth (0.2.0)
|
36
|
+
i18n (0.6.5)
|
37
|
+
jeweler (1.8.8)
|
38
|
+
builder
|
39
|
+
bundler (~> 1.0)
|
40
|
+
git (>= 1.2.5)
|
41
|
+
github_api (= 0.10.1)
|
42
|
+
highline (>= 1.6.15)
|
43
|
+
nokogiri (= 1.5.10)
|
44
|
+
rake
|
45
|
+
rdoc
|
46
|
+
json (1.8.1)
|
47
|
+
jwt (0.1.8)
|
48
|
+
multi_json (>= 1.5)
|
49
|
+
method_source (0.8.2)
|
50
|
+
minitest (4.7.5)
|
51
|
+
multi_json (1.8.2)
|
52
|
+
multi_test (0.0.2)
|
53
|
+
multi_xml (0.5.5)
|
54
|
+
multipart-post (1.2.0)
|
55
|
+
nokogiri (1.5.10)
|
56
|
+
oauth2 (0.9.2)
|
57
|
+
faraday (~> 0.8)
|
58
|
+
httpauth (~> 0.2)
|
59
|
+
jwt (~> 0.1.4)
|
60
|
+
multi_json (~> 1.0)
|
61
|
+
multi_xml (~> 0.5)
|
62
|
+
rack (~> 1.2)
|
63
|
+
pry (0.9.12.2)
|
64
|
+
coderay (~> 1.0.5)
|
65
|
+
method_source (~> 0.8)
|
66
|
+
slop (~> 3.4)
|
67
|
+
rack (1.5.2)
|
68
|
+
rake (10.1.0)
|
69
|
+
rdoc (3.12.2)
|
70
|
+
json (~> 1.4)
|
71
|
+
rspec (2.8.0)
|
72
|
+
rspec-core (~> 2.8.0)
|
73
|
+
rspec-expectations (~> 2.8.0)
|
74
|
+
rspec-mocks (~> 2.8.0)
|
75
|
+
rspec-core (2.8.0)
|
76
|
+
rspec-expectations (2.8.0)
|
77
|
+
diff-lcs (~> 1.1.2)
|
78
|
+
rspec-mocks (2.8.0)
|
79
|
+
simplecov (0.7.1)
|
80
|
+
multi_json (~> 1.0)
|
81
|
+
simplecov-html (~> 0.7.1)
|
82
|
+
simplecov-html (0.7.1)
|
83
|
+
slop (3.4.6)
|
84
|
+
thread_safe (0.1.3)
|
85
|
+
atomic
|
86
|
+
tzinfo (0.3.38)
|
87
|
+
yard (0.8.7.3)
|
88
|
+
|
89
|
+
PLATFORMS
|
90
|
+
ruby
|
91
|
+
|
92
|
+
DEPENDENCIES
|
93
|
+
activesupport
|
94
|
+
bundler (~> 1.0)
|
95
|
+
cucumber
|
96
|
+
jeweler (~> 1.8.7)
|
97
|
+
pry
|
98
|
+
rdoc (~> 3.12)
|
99
|
+
rspec (~> 2.8.0)
|
100
|
+
simplecov
|
101
|
+
yard (~> 0.7)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Dave Makena
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2013 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
= Eggs
|
2
|
+
|
3
|
+
Eggs handles the encryption and decryption of text and strings.
|
4
|
+
Where text is the actual content you wish to encrypt,
|
5
|
+
and key is the text you wish to decrypt with,
|
6
|
+
just call
|
7
|
+
Eggs.scramble(text, key)
|
8
|
+
to encrypt,
|
9
|
+
and call
|
10
|
+
Eggs.unscramble(text, key)
|
11
|
+
to decrypt.
|
12
|
+
If you need a key,
|
13
|
+
just call,
|
14
|
+
Eggs.key.
|
15
|
+
Happy coding!
|
16
|
+
|
17
|
+
= Rails 4
|
18
|
+
|
19
|
+
gem 'eggs'
|
20
|
+
|
21
|
+
bundle
|
22
|
+
|
23
|
+
gem install eggs
|
24
|
+
|
25
|
+
= Usage
|
26
|
+
|
27
|
+
== Eggs.scramble(text, key)
|
28
|
+
|
29
|
+
require 'eggs'
|
30
|
+
key = "8sFpMOjupOgV9STuwPqOXBBqUDEcEy"
|
31
|
+
text = scrambled = "dog"
|
32
|
+
scrambled == text #=> true
|
33
|
+
scrambled = Eggs.scramble(text, key) = "%ED%B6%E7%88%EC%A6g%81%17%A8%92]J%8A[%9C"
|
34
|
+
scrambled == text #=> false
|
35
|
+
|
36
|
+
== Eggs.unscramble(text, key)
|
37
|
+
|
38
|
+
require 'eggs'
|
39
|
+
key == "TxgOH3A8bqwd8L0jbcWoAA9ErKyppY"
|
40
|
+
text == "dog"
|
41
|
+
scrambled = Eggs.scramble(text, key) = "%05d%E2%A7+%FE%1D%16m%3C%B8%9F%D1%7D%5El"
|
42
|
+
scrambled == text #=> false
|
43
|
+
unscrambled = Eggs.unscramble(text, key) = "dog"
|
44
|
+
unscrambled == text #=> true
|
45
|
+
|
46
|
+
== Eggs.key
|
47
|
+
|
48
|
+
require 'eggs'
|
49
|
+
Eggs.key == "ENWi9n7n806DMU5USHE7Wbzy8iOZlc"
|
50
|
+
Eggs.key.size == 30
|
51
|
+
Eggs.key(10) == "6H3emLzzgw"
|
52
|
+
Eggs.key(10).size == 10
|
53
|
+
Eggs.key(3) == "aPY"
|
54
|
+
Eggs.key(3).size == 3
|
55
|
+
|
56
|
+
== Eggs.aes(command, text, key)
|
57
|
+
|
58
|
+
require 'eggs'
|
59
|
+
key == "BBCYjirFf8tqs4D3nFhukrRrtK144E"
|
60
|
+
text == "dog"
|
61
|
+
Eggs.aes(:encrypt, text, key) == "�=c�O�m2`�V�p��Y�<m:"
|
62
|
+
(2013-11-05: http://stackoverflow.com/questions/8489486/encryption-and-decryption-algorithm-in-rails)
|
63
|
+
|
64
|
+
== Contributing to eggs
|
65
|
+
|
66
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
67
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
68
|
+
* Fork the project.
|
69
|
+
* Start a feature/bugfix branch.
|
70
|
+
* Commit and push until you are happy with your contribution.
|
71
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
72
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
73
|
+
|
74
|
+
== Copyright
|
75
|
+
|
76
|
+
Copyright (c) 2013 Dave Makena. See LICENSE.txt for
|
77
|
+
further details.
|
78
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "eggs"
|
18
|
+
gem.homepage = "http://github.com/abcbots/eggs"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Eggs Scrambles and Unscrambles text and strings}
|
21
|
+
gem.description = %Q{Eggs Scrambles and Unscrambles (Encrypts and Decrypts) text and strings, and generates random keys of any length.}
|
22
|
+
gem.email = "davemakena@gmail.com"
|
23
|
+
gem.authors = ["Dave Makena"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
require 'cucumber/rake/task'
|
35
|
+
Cucumber::Rake::Task.new(:features)
|
36
|
+
|
37
|
+
task :default => :spec
|
38
|
+
|
39
|
+
require 'yard'
|
40
|
+
YARD::Rake::YardocTask.new
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.6
|
data/eggs.gemspec
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: eggs 0.0.6 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "eggs"
|
9
|
+
s.version = "0.0.6"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.authors = ["Dave Makena"]
|
13
|
+
s.date = "2013-11-05"
|
14
|
+
s.description = "Eggs Scrambles and Unscrambles (Encrypts and Decrypts) text and strings, and generates random keys of any length."
|
15
|
+
s.email = "davemakena@gmail.com"
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE.txt",
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".document",
|
22
|
+
".rspec",
|
23
|
+
"Gemfile",
|
24
|
+
"Gemfile.lock",
|
25
|
+
"LICENSE.txt",
|
26
|
+
"MIT-LICENSE",
|
27
|
+
"README.rdoc",
|
28
|
+
"Rakefile",
|
29
|
+
"VERSION",
|
30
|
+
"eggs.gemspec",
|
31
|
+
"features/eggs.feature",
|
32
|
+
"features/step_definitions/eggs_steps.rb",
|
33
|
+
"features/support/env.rb",
|
34
|
+
"lib/eggs.rb",
|
35
|
+
"spec/eggs_spec.rb",
|
36
|
+
"spec/spec_helper.rb"
|
37
|
+
]
|
38
|
+
s.homepage = "http://github.com/abcbots/eggs"
|
39
|
+
s.licenses = ["MIT"]
|
40
|
+
s.require_paths = ["lib"]
|
41
|
+
s.rubygems_version = "2.1.10"
|
42
|
+
s.summary = "Eggs Scrambles and Unscrambles text and strings"
|
43
|
+
|
44
|
+
if s.respond_to? :specification_version then
|
45
|
+
s.specification_version = 4
|
46
|
+
|
47
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
48
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 0"])
|
49
|
+
else
|
50
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
51
|
+
end
|
52
|
+
else
|
53
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
begin
|
3
|
+
Bundler.setup(:default, :development)
|
4
|
+
rescue Bundler::BundlerError => e
|
5
|
+
$stderr.puts e.message
|
6
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
7
|
+
exit e.status_code
|
8
|
+
end
|
9
|
+
|
10
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
11
|
+
require 'eggs'
|
12
|
+
|
13
|
+
require 'rspec/expectations'
|
data/lib/eggs.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# == Module is reachable via module name: Eggs....
|
2
|
+
module Eggs
|
3
|
+
|
4
|
+
# == Pry for debugging
|
5
|
+
require 'pry'
|
6
|
+
|
7
|
+
# == Eggs: scramble (text, key)
|
8
|
+
# require 'eggs'
|
9
|
+
# key = "8sFpMOjupOgV9STuwPqOXBBqUDEcEy"
|
10
|
+
# text = scrambled = "dog"
|
11
|
+
# scrambled == text #=> true
|
12
|
+
# scrambled = Eggs.scramble(text, key) = "%ED%B6%E7%88%EC%A6g%81%17%A8%92]J%8A[%9C"
|
13
|
+
# scrambled == text #=> false
|
14
|
+
#
|
15
|
+
def self.scramble(text, key)
|
16
|
+
return URI.encode aes(:encrypt, key, text)
|
17
|
+
end
|
18
|
+
|
19
|
+
# == Eggs: unscramble (text, key)
|
20
|
+
# require 'eggs'
|
21
|
+
# key == "TxgOH3A8bqwd8L0jbcWoAA9ErKyppY"
|
22
|
+
# text == "dog"
|
23
|
+
# scrambled = Eggs.scramble(text, key) = "%05d%E2%A7+%FE%1D%16m%3C%B8%9F%D1%7D%5El"
|
24
|
+
# scrambled == text #=> false
|
25
|
+
# unscrambled = Eggs.unscramble(text, key) = "dog"
|
26
|
+
# unscrambled == text #=> true
|
27
|
+
#
|
28
|
+
def self.unscramble(text, key)
|
29
|
+
aes(:decrypt, key, URI.decode(text))
|
30
|
+
end
|
31
|
+
|
32
|
+
# == Eggs: (generate a random) key
|
33
|
+
# require 'eggs'
|
34
|
+
# Eggs.key == "ENWi9n7n806DMU5USHE7Wbzy8iOZlc"
|
35
|
+
# Eggs.key.size == 30
|
36
|
+
# Eggs.key(10) == "6H3emLzzgw"
|
37
|
+
# Eggs.key(10).size == 10
|
38
|
+
# Eggs.key(3) == "aPY"
|
39
|
+
# Eggs.key(3).size == 3
|
40
|
+
#
|
41
|
+
def self.key(length=30)
|
42
|
+
length=length.to_i
|
43
|
+
s = SecureRandom.base64(length).split("")[1..length].join("").to_s
|
44
|
+
s = s.gsub("/", SecureRandom.hex(1).split("").first.to_s)
|
45
|
+
s = s.gsub("+", SecureRandom.hex(1).split("").first.to_s)
|
46
|
+
return s.gsub("==", SecureRandom.hex(1).split("").first.to_s)
|
47
|
+
end
|
48
|
+
|
49
|
+
# == Eggs: aes (command, text, key)
|
50
|
+
# require 'eggs'
|
51
|
+
# key == "BBCYjirFf8tqs4D3nFhukrRrtK144E"
|
52
|
+
# text == "dog"
|
53
|
+
# Eggs.aes(:encrypt, text, key) == "�=c�O�m2`�V�p��Y�<m:"
|
54
|
+
# Src: http://stackoverflow.com/questions/8489486/encryption-and-decryption-algorithm-in-rails
|
55
|
+
#
|
56
|
+
def self.aes(m,k,t)
|
57
|
+
(aes = OpenSSL::Cipher::Cipher.new('aes-256-cbc').send(m)).key = Digest::SHA256.digest(k)
|
58
|
+
return aes.update(t) << aes.final
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
data/spec/eggs_spec.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
require 'eggs'
|
4
|
+
|
5
|
+
describe "Eggs" do
|
6
|
+
|
7
|
+
it "generates keys" do
|
8
|
+
puts
|
9
|
+
puts "# == Eggs.key"
|
10
|
+
puts "require 'eggs'"
|
11
|
+
puts "Eggs.key == \"#{Eggs.key}\""
|
12
|
+
puts "Eggs.key.size == #{Eggs.key.size}"
|
13
|
+
puts "Eggs.key(10) == \"#{Eggs.key(10)}\""
|
14
|
+
puts "Eggs.key(10).size == #{Eggs.key(10).size}"
|
15
|
+
puts "Eggs.key(3) == \"#{Eggs.key(3)}\""
|
16
|
+
puts "Eggs.key(3).size == #{Eggs.key(3).size}"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "scrambles" do
|
20
|
+
puts
|
21
|
+
puts "# == Eggs.scramble(text, key)"
|
22
|
+
puts "require 'eggs'"
|
23
|
+
puts "key = \"#{key = Eggs.key}\""
|
24
|
+
puts "text = scrambled = \"#{text = scrambled = "dog"}\""
|
25
|
+
puts "scrambled == text #=> #{(scrambled == text).to_s}"
|
26
|
+
(scrambled==text).should eq(true)
|
27
|
+
puts "scrambled = Eggs.scramble(text, key) = \"#{scrambled = Eggs.scramble(text, key)}\""
|
28
|
+
puts "scrambled == text #=> #{(scrambled == text).to_s}"
|
29
|
+
(scrambled==text).should eq(false)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "unscrambles" do
|
33
|
+
puts
|
34
|
+
puts "# == Eggs.unscramble(text, key)"
|
35
|
+
puts "require 'eggs'"
|
36
|
+
puts "key == \"#{key = Eggs.key}\""
|
37
|
+
puts "text == \"#{text = "dog"}\""
|
38
|
+
puts "scrambled = Eggs.scramble(text, key) = \"#{scrambled = Eggs.scramble(text, key)}\""
|
39
|
+
puts "scrambled == text #=> #{(scrambled == text).to_s}"
|
40
|
+
(scrambled==text).should eq(false)
|
41
|
+
puts "unscrambled = Eggs.unscramble(text, key) = \"#{unscrambled = Eggs.unscramble(scrambled, key)}\""
|
42
|
+
puts "unscrambled == text #=> #{(unscrambled == text).to_s}"
|
43
|
+
(unscrambled==text).should eq(true)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "uses OpenSSL libraries to encrypt text with a key" do
|
47
|
+
puts
|
48
|
+
puts "# == Eggs.aes(command, text, key)"
|
49
|
+
puts "require 'eggs'"
|
50
|
+
puts "key == \"#{key = Eggs.key}\""
|
51
|
+
puts "text == \"#{text = "dog"}\""
|
52
|
+
puts "Eggs.aes(:encrypt, text, key) == \"#{scrambled = Eggs.aes(:encrypt, text, key)}\""
|
53
|
+
puts "Src: http://stackoverflow.com/questions/8489486/encryption-and-decryption-algorithm-in-rails"
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'eggs'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: eggs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dave Makena
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Eggs Scrambles and Unscrambles (Encrypts and Decrypts) text and strings,
|
28
|
+
and generates random keys of any length.
|
29
|
+
email: davemakena@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files:
|
33
|
+
- LICENSE.txt
|
34
|
+
- README.rdoc
|
35
|
+
files:
|
36
|
+
- .document
|
37
|
+
- .rspec
|
38
|
+
- Gemfile
|
39
|
+
- Gemfile.lock
|
40
|
+
- LICENSE.txt
|
41
|
+
- MIT-LICENSE
|
42
|
+
- README.rdoc
|
43
|
+
- Rakefile
|
44
|
+
- VERSION
|
45
|
+
- eggs.gemspec
|
46
|
+
- features/eggs.feature
|
47
|
+
- features/step_definitions/eggs_steps.rb
|
48
|
+
- features/support/env.rb
|
49
|
+
- lib/eggs.rb
|
50
|
+
- spec/eggs_spec.rb
|
51
|
+
- spec/spec_helper.rb
|
52
|
+
homepage: http://github.com/abcbots/eggs
|
53
|
+
licenses:
|
54
|
+
- MIT
|
55
|
+
metadata: {}
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 2.1.10
|
73
|
+
signing_key:
|
74
|
+
specification_version: 4
|
75
|
+
summary: Eggs Scrambles and Unscrambles text and strings
|
76
|
+
test_files: []
|