crypt_keeper 0.19.0 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2141c209434cabd811523c0c3be27aa602278aef
4
- data.tar.gz: c5c5f534bdd2ec9dacbbdeed57f9e2b80c7f6445
3
+ metadata.gz: 941281e7dbbeec5e9380afe59ebc80cf7b92a443
4
+ data.tar.gz: 05793997e6ffe8a14542b248a557a88cdd48a0ea
5
5
  SHA512:
6
- metadata.gz: 599ab56c6956a2eb1f8e817a25095ac77e48ea9a599700240569768e5f5d9d4d10e5ced9af6ddc328b5958145729d0866a444dd7a5f909fc3b188f9cdc581091
7
- data.tar.gz: 0c821d0952c356c791a0abf54e3e41c56a8c62a4c7134ee6b6950b43bf1c022f9031e40bd1e7eef62e8dcb8be86d14f7d8663334db52fd0d95fe6ac59abaf498
6
+ metadata.gz: 3a9bdf5f2b7a272aa6cfdf9e4d88b5b356bb93f1a1bc4651f62c17f529d934719e6225d23358be88994f71228d96b16ceb7757fc0f47538a30d956e0a87213aa
7
+ data.tar.gz: 6ea7b91da4c33a85b17ffacc98235c67c75929528ae45894e4618420481666b5029c27dab4b69e128c4536c0a145146983cd2b5e774046035c6e204d6f0c8064
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- crypt_keeper (0.18.4)
4
+ crypt_keeper (0.19.0)
5
5
  activerecord (>= 3.1, < 4.3)
6
6
  activesupport (>= 3.1, < 4.3)
7
7
  aes (~> 0.5.0)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- crypt_keeper (0.18.4)
4
+ crypt_keeper (0.19.0)
5
5
  activerecord (>= 3.1, < 4.3)
6
6
  activesupport (>= 3.1, < 4.3)
7
7
  aes (~> 0.5.0)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- crypt_keeper (0.18.4)
4
+ crypt_keeper (0.19.0)
5
5
  activerecord (>= 3.1, < 4.3)
6
6
  activesupport (>= 3.1, < 4.3)
7
7
  aes (~> 0.5.0)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- crypt_keeper (0.18.4)
4
+ crypt_keeper (0.19.0)
5
5
  activerecord (>= 3.1, < 4.3)
6
6
  activesupport (>= 3.1, < 4.3)
7
7
  aes (~> 0.5.0)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- crypt_keeper (0.18.4)
4
+ crypt_keeper (0.19.0)
5
5
  activerecord (>= 3.1, < 4.3)
6
6
  activesupport (>= 3.1, < 4.3)
7
7
  aes (~> 0.5.0)
@@ -98,6 +98,22 @@ module CryptKeeper
98
98
  end
99
99
  end
100
100
 
101
+ # Public: Decrypt a table (reverse of encrypt_table!)
102
+ def decrypt_table!
103
+ enc = encryptor_klass.new(crypt_keeper_options)
104
+ tmp_table = Class.new(ActiveRecord::Base).tap { |c| c.table_name = self.table_name }
105
+
106
+ transaction do
107
+ tmp_table.find_each do |r|
108
+ crypt_keeper_fields.each do |field|
109
+ r.send("#{field}=", enc.decrypt(r[field])) if r[field].present?
110
+ end
111
+
112
+ r.save!
113
+ end
114
+ end
115
+ end
116
+
101
117
  private
102
118
 
103
119
  # Private: The encryptor class
@@ -1,3 +1,3 @@
1
1
  module CryptKeeper
2
- VERSION = "0.19.0"
2
+ VERSION = "0.20.0"
3
3
  end
data/spec/model_spec.rb CHANGED
@@ -124,6 +124,21 @@ module CryptKeeper
124
124
  end
125
125
  end
126
126
 
127
+ context "Table Decryption (Reverse of Initial Table Encryption)" do
128
+ subject { create_encrypted_model :storage, key: 'tool', salt: 'salt', encryptor: :aes_new }
129
+ let!(:storage_entries) { 5.times.map { |i| "testing#{i}" } }
130
+
131
+ before do
132
+ subject.delete_all
133
+ storage_entries.each { |entry| subject.create! storage: entry}
134
+ end
135
+
136
+ it "decrypts the table" do
137
+ subject.decrypt_table!
138
+ expect( create_model.first(5).map(&:storage) ).to eq( storage_entries )
139
+ end
140
+ end
141
+
127
142
  context "Missing Attributes" do
128
143
  subject { create_encrypted_model :storage, key: 'tool', salt: 'salt', encryptor: :aes_new, encoding: 'utf-8' }
129
144
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crypt_keeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.0
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Mazzi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-02 00:00:00.000000000 Z
11
+ date: 2015-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord