devise_encryptable_aes 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/devise/encryptable/encryptors/aes256.rb +34 -0
- data/lib/devise_encryptable_aes.rb +1 -5
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0d9a32775fffbb8f09338f8c710b7fd4a35016d0bb6a54c62c54601873dc4ef
|
4
|
+
data.tar.gz: 7389a7a3d98e9e4a7ed346a6d04743ba887d382765eeb0e682e4e31ff62d0a5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 783ca4cae910bae57248e20a5ed5007c59335c1486e5b7a2a9ca4145e450987c21e11990eed015a18c26bfc188a67cd7fd1343a03df5fc42c7d4bbbe68c48f28
|
7
|
+
data.tar.gz: f554575575ed449fa7dbffca2c82e0cafc41b9158d3743907961f1e1c41250ddd26b7711fab5f8605c4a30736d3ee69f6fa199db76a4b9286213a570a3aaca7b
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aes'
|
4
|
+
require 'devise/encryptable/encryptors/base'
|
5
|
+
|
6
|
+
module Devise
|
7
|
+
module Encryptable
|
8
|
+
module Encryptors
|
9
|
+
class Aes256 < Base
|
10
|
+
class << self
|
11
|
+
def digest(password, _stretches, salt, pepper)
|
12
|
+
::AES.encrypt(password, pepper, { iv: salt }) if password
|
13
|
+
rescue StandardError
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
|
17
|
+
def salt(_stretches)
|
18
|
+
::AES.iv(:base_64)
|
19
|
+
end
|
20
|
+
|
21
|
+
def decrypt(encrypted_password, pepper)
|
22
|
+
::AES.decrypt(encrypted_password, pepper)
|
23
|
+
end
|
24
|
+
|
25
|
+
def compare(encrypted_password, password, pepper)
|
26
|
+
return false if encrypted_password.blank?
|
27
|
+
|
28
|
+
decrypt(encrypted_password, pepper) == password
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_encryptable_aes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pham Tat Dat
|
@@ -10,14 +10,15 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2023-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: ''
|
14
14
|
email: tatdat97dhbkhn@gmail.com
|
15
15
|
executables: []
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
|
+
- lib/devise/encryptable/encryptors/aes256.rb
|
19
20
|
- lib/devise_encryptable_aes.rb
|
20
|
-
homepage: https://
|
21
|
+
homepage: https://github.com/tatdat97dhbkhn/devise_encryptable_aes
|
21
22
|
licenses:
|
22
23
|
- MIT
|
23
24
|
metadata: {}
|
@@ -39,5 +40,5 @@ requirements: []
|
|
39
40
|
rubygems_version: 3.4.9
|
40
41
|
signing_key:
|
41
42
|
specification_version: 4
|
42
|
-
summary:
|
43
|
+
summary: Add AES encryption support for Devise
|
43
44
|
test_files: []
|