symmetric-encryption 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +41 -11
- data/Rakefile +3 -3
- data/lib/symmetric-encryption.rb +10 -7
- data/lib/symmetric_encryption/cipher.rb +114 -0
- data/lib/{symmetric → symmetric_encryption}/extensions/active_record/base.rb +4 -7
- data/lib/{symmetric → symmetric_encryption}/extensions/mongoid/fields.rb +19 -10
- data/lib/{symmetric → symmetric_encryption}/railtie.rb +4 -4
- data/lib/{symmetric → symmetric_encryption}/railties/symmetric_encryption.rake +5 -5
- data/lib/{symmetric/railties/symmetric_encrypted_validator.rb → symmetric_encryption/railties/symmetric_encryption_validator.rb} +4 -4
- data/lib/symmetric_encryption/reader.rb +221 -0
- data/lib/symmetric_encryption/symmetric_encryption.rb +280 -0
- data/lib/symmetric_encryption/version.rb +4 -0
- data/lib/symmetric_encryption/writer.rb +132 -0
- data/nbproject/private/private.xml +14 -1
- data/symmetric-encryption-0.2.0.gem +0 -0
- data/symmetric-encryption-0.4.0.gem +0 -0
- data/test/attr_encrypted_test.rb +7 -7
- data/test/cipher_test.rb +8 -13
- data/test/field_encrypted_test.rb +3 -3
- data/test/reader_test.rb +76 -0
- data/test/symmetric_encryption_test.rb +53 -0
- data/test/writer_test.rb +56 -0
- metadata +20 -15
- data/lib/symmetric/cipher.rb +0 -184
- data/lib/symmetric/encryption.rb +0 -262
- data/lib/symmetric/version.rb +0 -4
- data/symmetric-encryption-0.3.0.gem +0 -0
- data/symmetric-encryption-0.3.1.gem +0 -0
- data/test/encryption_test.rb +0 -51
data/lib/symmetric/version.rb
DELETED
Binary file
|
Binary file
|
data/test/encryption_test.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
# Allow examples to be run in-place without requiring a gem install
|
2
|
-
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
3
|
-
|
4
|
-
require 'rubygems'
|
5
|
-
require 'test/unit'
|
6
|
-
require 'shoulda'
|
7
|
-
|
8
|
-
Symmetric::Encryption.load!(File.join(File.dirname(__FILE__), 'config', 'symmetric-encryption.yml'), 'test')
|
9
|
-
|
10
|
-
# Unit Test for Symmetric::Encryption
|
11
|
-
#
|
12
|
-
class EncryptionTest < Test::Unit::TestCase
|
13
|
-
context 'initialized' do
|
14
|
-
|
15
|
-
context 'Symmetric::Encryption configuration' do
|
16
|
-
setup do
|
17
|
-
@config = Symmetric::Encryption.send(:read_config, File.join(File.dirname(__FILE__), 'config', 'symmetric-encryption.yml'), 'test')
|
18
|
-
end
|
19
|
-
|
20
|
-
should "match config file" do
|
21
|
-
assert_equal @config[:ciphers][0][:cipher], Symmetric::Encryption.cipher.cipher
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'Symmetric::Encryption tests' do
|
26
|
-
setup do
|
27
|
-
@social_security_number = "987654321"
|
28
|
-
@social_security_number_encrypted = "S+8X1NRrqdfEIQyFHVPuVA==\n"
|
29
|
-
@social_security_number_encrypted_with_secondary_1 = "D1UCu38pqJ3jc0GvwJHiow==\n"
|
30
|
-
end
|
31
|
-
|
32
|
-
should "encrypt simple string" do
|
33
|
-
assert_equal @social_security_number_encrypted, Symmetric::Encryption.encrypt(@social_security_number)
|
34
|
-
end
|
35
|
-
|
36
|
-
should "decrypt string" do
|
37
|
-
assert_equal @social_security_number, Symmetric::Encryption.decrypt(@social_security_number_encrypted)
|
38
|
-
end
|
39
|
-
|
40
|
-
should "determine if string is encrypted" do
|
41
|
-
assert_equal true, Symmetric::Encryption.encrypted?(@social_security_number_encrypted)
|
42
|
-
assert_equal false, Symmetric::Encryption.encrypted?(@social_security_number)
|
43
|
-
end
|
44
|
-
|
45
|
-
should "decrypt with secondary key when first one fails" do
|
46
|
-
assert_equal @social_security_number, Symmetric::Encryption.decrypt(@social_security_number_encrypted)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|