crypt_keeper_providers 0.5.0 → 0.5.1

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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /home/justin/work/ruby/crypt_keeper_providers
3
3
  specs:
4
- crypt_keeper_providers (0.5.0)
4
+ crypt_keeper_providers (0.5.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /home/justin/work/ruby/crypt_keeper_providers
3
3
  specs:
4
- crypt_keeper_providers (0.5.0)
4
+ crypt_keeper_providers (0.5.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /home/justin/work/ruby/crypt_keeper_providers
3
3
  specs:
4
- crypt_keeper_providers (0.5.0)
4
+ crypt_keeper_providers (0.5.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -30,6 +30,7 @@ module CryptKeeperProviders
30
30
  #
31
31
  # Returns a string
32
32
  def encrypt(value)
33
+ return if value.nil?
33
34
  aes.encrypt
34
35
  aes.key = key
35
36
  iv = rand.to_s
@@ -41,6 +42,7 @@ module CryptKeeperProviders
41
42
  #
42
43
  # Returns a string
43
44
  def decrypt(value)
45
+ return if value.nil?
44
46
  iv, value = Base64::decode64(value.to_s).split(SEPARATOR)
45
47
  aes.decrypt
46
48
  aes.key = key
@@ -18,6 +18,7 @@ module CryptKeeperProviders
18
18
  #
19
19
  # Returns an encrypted string
20
20
  def encrypt(value)
21
+ return if value.nil?
21
22
  Base64.encode64 escape_and_execute_sql(
22
23
  ["SELECT AES_ENCRYPT(?, ?)", value, key]).first
23
24
  end
@@ -26,6 +27,7 @@ module CryptKeeperProviders
26
27
  #
27
28
  # Returns a plaintext string
28
29
  def decrypt(value)
30
+ return if value.nil?
29
31
  escape_and_execute_sql(
30
32
  ["SELECT AES_DECRYPT(?, ?)", Base64.decode64(value), key]).first
31
33
  end
@@ -1,3 +1,3 @@
1
1
  module CryptKeeperProviders
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
data/spec/aes_spec.rb CHANGED
@@ -28,6 +28,10 @@ module CryptKeeperProviders
28
28
  encrypted.should_not be_nil
29
29
  encrypted.should_not be_empty
30
30
  end
31
+
32
+ it "should not encrypt nil" do
33
+ subject.encrypt(nil).should be_nil
34
+ end
31
35
  end
32
36
 
33
37
  describe "#decrypt" do
@@ -38,6 +42,10 @@ module CryptKeeperProviders
38
42
  it "should decrypt the string" do
39
43
  decrypted.should == 'string'
40
44
  end
45
+
46
+ it "should not decrypt nil" do
47
+ subject.decrypt(nil).should be_nil
48
+ end
41
49
  end
42
50
  end
43
51
  end
@@ -22,12 +22,20 @@ module CryptKeeperProviders
22
22
  subject.encrypt(plain_text).should_not == plain_text
23
23
  subject.encrypt(plain_text).should_not be_empty
24
24
  end
25
+
26
+ it "should not encrypt nil" do
27
+ subject.encrypt(nil).should be_nil
28
+ end
25
29
  end
26
30
 
27
31
  describe "#decrypt" do
28
32
  it "should decrypt the string" do
29
33
  subject.decrypt(cipher_text).should == plain_text
30
34
  end
35
+
36
+ it "should not decrypt nil" do
37
+ subject.decrypt(nil).should be_nil
38
+ end
31
39
  end
32
40
  end
33
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crypt_keeper_providers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -191,7 +191,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
191
191
  version: '0'
192
192
  segments:
193
193
  - 0
194
- hash: -3721720512107072383
194
+ hash: 1788939699789184326
195
195
  required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  none: false
197
197
  requirements:
@@ -200,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
200
  version: '0'
201
201
  segments:
202
202
  - 0
203
- hash: -3721720512107072383
203
+ hash: 1788939699789184326
204
204
  requirements: []
205
205
  rubyforge_project:
206
206
  rubygems_version: 1.8.23