lite-encryption 1.0.0 → 1.0.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/README.md +8 -9
- data/lib/generators/lite/encryption/templates/install.rb +2 -2
- data/lib/lite/encryption.rb +1 -1
- data/lib/lite/encryption/configuration.rb +2 -4
- data/lib/lite/encryption/key.rb +26 -0
- data/lib/lite/encryption/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e5dbff683b56821e5cc5cffca290b4b6a63273a0adc46507ade25394a88e986
|
4
|
+
data.tar.gz: c3264eba8d78cbf8088e1e2782eafb7c5bd5f54ece8896e82850e714873b2859
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9076047d3c5cd4286cd6a75ec870a04e6f5cd983a0ceb9e198efdee538224beccc23364f8747d454582248b71fd6eb59bf875b5f03c953d6e523015d2b00bccc
|
7
|
+
data.tar.gz: afe7e6507321ebf8d2b166e3f0c30b7c244106915d4cff946926c3e42ec7dfa22822d18cc1694eb9c49a2d3b222b401b9c6332bccadde632a8bf7bee31a8d2f0
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [1.0.0] - 2019-08-26
|
10
|
+
### Added
|
11
|
+
- Key class for key generation
|
12
|
+
### Changed
|
13
|
+
- Update initializer file
|
14
|
+
|
9
15
|
## [1.0.0] - 2019-08-24
|
10
16
|
### Added
|
11
17
|
- Initial project version
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -25,6 +25,7 @@ Or install it yourself as:
|
|
25
25
|
## Table of Contents
|
26
26
|
|
27
27
|
* [Configurations](#configurations)
|
28
|
+
* [Key](#key)
|
28
29
|
* [Message](#message)
|
29
30
|
* [Attribute](#attribute)
|
30
31
|
|
@@ -35,20 +36,18 @@ Or install it yourself as:
|
|
35
36
|
|
36
37
|
```ruby
|
37
38
|
Lite::Encryption.configure do |config|
|
38
|
-
config.secret_key_base =
|
39
|
-
config.secret_key_salt =
|
39
|
+
config.secret_key_base = ENV['SECRET_KEY_BASE']
|
40
|
+
config.secret_key_salt = ENV['SECRET_KEY_SALT']
|
40
41
|
end
|
41
42
|
```
|
42
43
|
|
43
|
-
|
44
|
-
|
44
|
+
## Key
|
45
|
+
|
46
|
+
Use the following to generate a base and salt key.
|
45
47
|
|
46
|
-
To generate a `secret_key_base`, execute `bundle exec rails secret` in the terminal prompt.
|
47
|
-
To generate a `secret_key_salt`, execute the following command in the Rails console prompt:
|
48
48
|
```ruby
|
49
|
-
|
50
|
-
|
51
|
-
)
|
49
|
+
Lite::Encryption::Key.generate_base #=> "b912e83c02b44122e31809a7435bc91e2e48c88742365aaccb07283eeb0379909e9aa09d64fc27cb5f20c3f072cd69aacd57518916799c00d41d94c06c916f5c"
|
50
|
+
Lite::Encryption::Key.generate_salt #=> "\xD5\x8C\xB6\x14\xAC\xC7-&\xAEu\xDDj\x80/\xDF\x15\xD1\xB2\x13\x04\x85\b\x8F\xC6ZQ`Z\xC7\xD4q\xDE"
|
52
51
|
```
|
53
52
|
|
54
53
|
## Message
|
data/lib/lite/encryption.rb
CHANGED
@@ -7,12 +7,10 @@ module Lite
|
|
7
7
|
|
8
8
|
attr_accessor :secret_key_base, :secret_key_salt
|
9
9
|
|
10
|
-
# rubocop:disable Metrics/LineLength
|
11
10
|
def initialize
|
12
|
-
@secret_key_base =
|
13
|
-
@secret_key_salt =
|
11
|
+
@secret_key_base = Lite::Encryption::Key.generate_base
|
12
|
+
@secret_key_salt = Lite::Encryption::Key.generate_salt
|
14
13
|
end
|
15
|
-
# rubocop:enable Metrics/LineLength
|
16
14
|
|
17
15
|
end
|
18
16
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/message_encryptor'
|
4
|
+
require 'securerandom'
|
5
|
+
|
6
|
+
module Lite
|
7
|
+
module Encryption
|
8
|
+
class Key
|
9
|
+
|
10
|
+
LENGTH ||= ActiveSupport::MessageEncryptor.key_len
|
11
|
+
|
12
|
+
class << self
|
13
|
+
|
14
|
+
def generate_base
|
15
|
+
SecureRandom.hex(LENGTH * 2)
|
16
|
+
end
|
17
|
+
|
18
|
+
def generate_salt
|
19
|
+
SecureRandom.random_bytes(LENGTH)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lite-encryption
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -219,6 +219,7 @@ files:
|
|
219
219
|
- lib/lite/encryption.rb
|
220
220
|
- lib/lite/encryption/attribute.rb
|
221
221
|
- lib/lite/encryption/configuration.rb
|
222
|
+
- lib/lite/encryption/key.rb
|
222
223
|
- lib/lite/encryption/message.rb
|
223
224
|
- lib/lite/encryption/version.rb
|
224
225
|
- lite-encryption.gemspec
|