devise_aes_encryptable 0.2.1 → 0.2.2

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{devise_aes_encryptable}
8
- s.version = "0.2.1"
8
+ s.version = "0.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Carl Hicks"]
12
- s.date = %q{2011-01-03}
12
+ s.date = %q{2011-01-15}
13
13
  s.description = %q{Adds Devise::Encryptors::Aes256.digest and Devise::Encryptors::Aes256.decrypt}
14
14
  s.email = %q{carl.hicks@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -10,14 +10,17 @@ module Devise
10
10
  # and the initialization_vector is randomly generated and prepended onto
11
11
  # encoded ciphertext
12
12
  def digest(password, stretches, salt, pepper)
13
- digest = ::AES.encrypt(password, pepper, {:iv => salt})
13
+ ::AES.encrypt(password, pepper, {:iv => salt})
14
14
  end
15
15
  alias :encrypt :digest
16
-
16
+ # Returns a base64 encoded salt
17
+ def salt(stretches)
18
+ ::AES.iv(:base_64)
19
+ end
17
20
  # Returns the plaintext password where pepper is used for the key,
18
21
  # and the initialization_vector is read from the Base64 encoded ciphertext
19
22
  def decrypt(encrypted_password, pepper)
20
- password = ::AES.decrypt(encrypted_password, pepper)
23
+ ::AES.decrypt(encrypted_password, pepper)
21
24
  end
22
25
  end
23
26
  end
@@ -8,7 +8,8 @@ class TestDeviseAesEncryptable < Test::Unit::TestCase
8
8
  should "encrypt and decrypt a password" do
9
9
  plain_text = "A super secret password"
10
10
  pepper = "eaa15a1fb0b0707ba443f7ce52a5a0e345391ff83b9955342d2a8e1c755fcd868ba4fb3c156166e13c9d4080cf2b505b4a383adc553c9567d75e3585cbccff98"
11
- cipher_text = Devise::Encryptors::Aes256.digest(plain_text, 0, nil, pepper)
11
+ salt = Devise::Encryptors::Aes256.salt(nil)
12
+ cipher_text = Devise::Encryptors::Aes256.digest(plain_text, 0, salt, pepper)
12
13
  assert_equal plain_text, Devise::Encryptors::Aes256.decrypt(cipher_text, pepper)
13
14
  end
14
15
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_aes_encryptable
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Carl Hicks
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-03 00:00:00 -08:00
18
+ date: 2011-01-15 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency