devise_aes_encryptable 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/devise_aes_encryptable.gemspec +2 -2
- data/lib/encryptors/aes256.rb +6 -3
- data/test/test_devise_aes_encryptable.rb +2 -1
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
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.
|
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-
|
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 = [
|
data/lib/encryptors/aes256.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
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-
|
18
|
+
date: 2011-01-15 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|