symmetric-encryption 3.7.2 → 3.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +65 -83
- data/Rakefile +4 -4
- data/lib/rails/generators/symmetric_encryption/config/config_generator.rb +3 -3
- data/lib/rails/generators/symmetric_encryption/heroku_config/heroku_config_generator.rb +3 -3
- data/lib/rails/generators/symmetric_encryption/new_keys/new_keys_generator.rb +2 -2
- data/lib/symmetric_encryption.rb +7 -1
- data/lib/symmetric_encryption/cipher.rb +180 -50
- data/lib/symmetric_encryption/coerce.rb +75 -0
- data/lib/symmetric_encryption/config.rb +88 -0
- data/lib/symmetric_encryption/extensions/active_record/base.rb +2 -2
- data/lib/symmetric_encryption/extensions/mongoid/encrypted.rb +2 -2
- data/lib/symmetric_encryption/generator.rb +5 -1
- data/lib/symmetric_encryption/railtie.rb +3 -3
- data/lib/symmetric_encryption/railties/symmetric_encryption.rake +6 -6
- data/lib/symmetric_encryption/railties/symmetric_encryption_validator.rb +1 -1
- data/lib/symmetric_encryption/reader.rb +16 -14
- data/lib/symmetric_encryption/symmetric_encryption.rb +30 -285
- data/lib/symmetric_encryption/version.rb +1 -1
- data/lib/symmetric_encryption/writer.rb +13 -13
- data/test/active_record_test.rb +126 -73
- data/test/cipher_test.rb +42 -42
- data/test/mongo_mapper_test.rb +171 -114
- data/test/mongoid_test.rb +173 -115
- data/test/reader_test.rb +63 -63
- data/test/symmetric_encryption_test.rb +81 -80
- data/test/test_db.sqlite3 +0 -0
- data/test/test_helper.rb +1 -2
- data/test/writer_test.rb +20 -20
- metadata +13 -13
- data/lib/_test_empty +0 -0
data/test/test_db.sqlite3
CHANGED
Binary file
|
data/test/test_helper.rb
CHANGED
@@ -4,12 +4,11 @@ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
|
4
4
|
require 'yaml'
|
5
5
|
require 'minitest/autorun'
|
6
6
|
require 'minitest/reporters'
|
7
|
-
require 'minitest/stub_any_instance'
|
8
|
-
require 'shoulda/context'
|
9
7
|
require 'semantic_logger'
|
10
8
|
# Since we want both the AR and Mongoid extensions loaded we need to require them first
|
11
9
|
require 'active_record'
|
12
10
|
require 'symmetric-encryption'
|
11
|
+
require 'awesome_print'
|
13
12
|
|
14
13
|
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
|
15
14
|
|
data/test/writer_test.rb
CHANGED
@@ -4,31 +4,31 @@ require 'stringio'
|
|
4
4
|
# Unit Test for Symmetric::EncryptedStream
|
5
5
|
#
|
6
6
|
class WriterTest < Minitest::Test
|
7
|
-
|
8
|
-
|
9
|
-
@data
|
7
|
+
describe SymmetricEncryption::Writer do
|
8
|
+
before do
|
9
|
+
@data = [
|
10
10
|
"Hello World\n",
|
11
11
|
"Keep this secret\n",
|
12
12
|
"And keep going even further and further..."
|
13
13
|
]
|
14
|
-
@data_str
|
15
|
-
@data_len
|
16
|
-
cipher
|
17
|
-
before
|
14
|
+
@data_str = @data.inject('') { |sum, str| sum << str }
|
15
|
+
@data_len = @data_str.length
|
16
|
+
cipher = SymmetricEncryption.cipher
|
17
|
+
before = cipher.always_add_header
|
18
18
|
cipher.always_add_header = false
|
19
|
-
@data_encrypted
|
19
|
+
@data_encrypted = SymmetricEncryption.cipher.binary_encrypt(@data_str, false, false)
|
20
20
|
cipher.always_add_header = before
|
21
|
-
@filename
|
21
|
+
@filename = '._test'
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
after do
|
25
25
|
File.delete(@filename) if File.exist?(@filename)
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
stream
|
30
|
-
file
|
31
|
-
written_len = @data.inject(0) {|sum,str| sum + file.write(str)}
|
28
|
+
it "encrypt to string stream" do
|
29
|
+
stream = StringIO.new
|
30
|
+
file = SymmetricEncryption::Writer.new(stream, header: false, random_key: false, random_iv: false)
|
31
|
+
written_len = @data.inject(0) { |sum, str| sum + file.write(str) }
|
32
32
|
assert_equal @data_len, file.size
|
33
33
|
file.close
|
34
34
|
|
@@ -38,24 +38,24 @@ class WriterTest < Minitest::Test
|
|
38
38
|
assert_equal @data_encrypted, result
|
39
39
|
end
|
40
40
|
|
41
|
-
|
41
|
+
it "encrypt to string stream using .open" do
|
42
42
|
written_len = 0
|
43
|
-
stream
|
43
|
+
stream = StringIO.new
|
44
44
|
SymmetricEncryption::Writer.open(stream) do |file|
|
45
|
-
written_len = @data.inject(0) {|sum,str| sum + file.write(str)}
|
45
|
+
written_len = @data.inject(0) { |sum, str| sum + file.write(str) }
|
46
46
|
assert_equal @data_len, file.size
|
47
47
|
end
|
48
48
|
assert_equal @data_len, written_len
|
49
49
|
end
|
50
50
|
|
51
|
-
|
51
|
+
it "encrypt to file using .open" do
|
52
52
|
written_len = nil
|
53
53
|
SymmetricEncryption::Writer.open(@filename, header: false, random_key: false, random_iv: false) do |file|
|
54
|
-
written_len = @data.inject(0) {|sum,str| sum + file.write(str)}
|
54
|
+
written_len = @data.inject(0) { |sum, str| sum + file.write(str) }
|
55
55
|
assert_equal @data_len, file.size
|
56
56
|
end
|
57
57
|
assert_equal @data_len, written_len
|
58
|
-
assert_equal @data_encrypted, File.open(@filename, 'rb') {|f| f.read }
|
58
|
+
assert_equal @data_encrypted, File.open(@filename, 'rb') { |f| f.read }
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
metadata
CHANGED
@@ -1,32 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: symmetric-encryption
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reid Morrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coercible
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0
|
19
|
+
version: '1.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.0
|
27
|
-
description:
|
28
|
-
passwords in configuration files
|
29
|
-
streaming
|
26
|
+
version: '1.0'
|
27
|
+
description: Transparently encrypt ActiveRecord, Mongoid, and MongoMapper attributes.
|
28
|
+
Encrypt passwords in configuration files. Encrypt entire files at rest.
|
30
29
|
email:
|
31
30
|
- reidmo@gmail.com
|
32
31
|
executables: []
|
@@ -37,7 +36,6 @@ files:
|
|
37
36
|
- README.md
|
38
37
|
- Rakefile
|
39
38
|
- examples/symmetric-encryption.yml
|
40
|
-
- lib/_test_empty
|
41
39
|
- lib/rails/generators/symmetric_encryption/config/config_generator.rb
|
42
40
|
- lib/rails/generators/symmetric_encryption/config/templates/symmetric-encryption.yml
|
43
41
|
- lib/rails/generators/symmetric_encryption/heroku_config/heroku_config_generator.rb
|
@@ -46,6 +44,8 @@ files:
|
|
46
44
|
- lib/symmetric-encryption.rb
|
47
45
|
- lib/symmetric_encryption.rb
|
48
46
|
- lib/symmetric_encryption/cipher.rb
|
47
|
+
- lib/symmetric_encryption/coerce.rb
|
48
|
+
- lib/symmetric_encryption/config.rb
|
49
49
|
- lib/symmetric_encryption/exception.rb
|
50
50
|
- lib/symmetric_encryption/extensions/active_record/base.rb
|
51
51
|
- lib/symmetric_encryption/extensions/mongo_mapper/plugins/encrypted_key.rb
|
@@ -77,7 +77,7 @@ files:
|
|
77
77
|
- test/test_db.sqlite3
|
78
78
|
- test/test_helper.rb
|
79
79
|
- test/writer_test.rb
|
80
|
-
homepage:
|
80
|
+
homepage: http://reidmorrison.github.io/symmetric-encryption/
|
81
81
|
licenses:
|
82
82
|
- Apache License V2.0
|
83
83
|
metadata: {}
|
@@ -97,10 +97,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
97
|
version: '0'
|
98
98
|
requirements: []
|
99
99
|
rubyforge_project:
|
100
|
-
rubygems_version: 2.4.
|
100
|
+
rubygems_version: 2.4.5.1
|
101
101
|
signing_key:
|
102
102
|
specification_version: 4
|
103
|
-
summary:
|
103
|
+
summary: Encryption for Ruby, and Ruby on Rails
|
104
104
|
test_files:
|
105
105
|
- test/active_record_test.rb
|
106
106
|
- test/cipher_test.rb
|
data/lib/_test_empty
DELETED
Binary file
|