lite-encryption 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e6341e27bca450a794f52c1e212acceb3c0ba906283183090d9b74cba762727
4
- data.tar.gz: 354c78a0d9ee5ad39ce6ed00fae615ee57978b3368f7403b58f551b8e51488f3
3
+ metadata.gz: 1e5dbff683b56821e5cc5cffca290b4b6a63273a0adc46507ade25394a88e986
4
+ data.tar.gz: c3264eba8d78cbf8088e1e2782eafb7c5bd5f54ece8896e82850e714873b2859
5
5
  SHA512:
6
- metadata.gz: b2147b276a2324dcb858ba53809f2ba8be89d2bdac581bdef7d67a852ed5c1dd8821d3131367d799bfa5411bd296f99f48d9120d771cbf3b374af429ab419b6c
7
- data.tar.gz: 1d0829e71711850aaf6767c865c47ad136a017086493ff388703b5cb4c4200eb7524c812bd5ac1679e9aa953112fc4b69b65a6666ab17baee4efaf2e9f6a45ce
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-encryption (1.0.0)
4
+ lite-encryption (1.0.1)
5
5
  activesupport
6
6
 
7
7
  GEM
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 = nil
39
- config.secret_key_salt = nil
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
- `secret_key_base` and `secret_key_salt` should be supplied via environment variables or a secret
44
- management system.
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
- SecureRandom.random_bytes(
50
- ActiveSupport::MessageEncryptor.key_len
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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Lite::Encryption.configure do |config|
4
- config.secret_key_base = nil
5
- config.secret_key_salt = nil
4
+ config.secret_key_base = ENV['SECRET_KEY_BASE']
5
+ config.secret_key_salt = ENV['SECRET_KEY_SALT']
6
6
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- %w[version configuration message attribute].each do |filename|
3
+ %w[version key configuration message attribute].each do |filename|
4
4
  require "lite/encryption/#{filename}"
5
5
  end
6
6
 
@@ -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 = 'b912e83c02b44122e31809a7435bc91e2e48c88742365aaccb07283eeb0379909e9aa09d64fc27cb5f20c3f072cd69aacd57518916799c00d41d94c06c916f5c'
13
- @secret_key_salt = "\xD5\x8C\xB6\x14\xAC\xC7-&\xAEu\xDDj\x80/\xDF\x15\xD1\xB2\x13\x04\x85\b\x8F\xC6ZQ`Z\xC7\xD4q\xDE"
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
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Encryption
5
5
 
6
- VERSION ||= '1.0.0'
6
+ VERSION ||= '1.0.1'
7
7
 
8
8
  end
9
9
  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.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-25 00:00:00.000000000 Z
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