encrypt_env 1.0.2 → 1.0.3

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/encrypt_env.rb +5 -5
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e693dd23d4628870c64fd6709d83263b8c47ce1adbb38a894be301b9352d9d9
4
- data.tar.gz: 2b0d99cd7ebee8c8696be54d3aedb3a9b0932570b180b5096263b4ec7de591ca
3
+ metadata.gz: d217182e6e069cf4770565d83ed33a7fd1f54a23943af63c06af79ce7fca4fd0
4
+ data.tar.gz: 161b25525ea4eb6dc6fd05a04aa633f7d94d967d829838ef43a3596c530c7566
5
5
  SHA512:
6
- metadata.gz: e2f5ae62315c67e5263c832c265143b63f4606372b6696bae32d97664aa292015469be681be58f453b2dd6a81210394f83bdc8a4d7850fe4eb871f6cea877de1
7
- data.tar.gz: 647cce7fadde39fb6365ac920da670173f956ec851b09c98122fe7df24a40a98d0fa9165910dca36af41a128887282230d0653ad03dfeb820f0a04faf8ea17d8
6
+ metadata.gz: 987b7459d6e5690f628c1bad633baefa99acc72be2e89863afe92c40f9583a3b956ae75e030b2349d0bb653f1dc7e10bf030dab75b483585e528fefac8bf2deb
7
+ data.tar.gz: 2fb65a9c5353683db33d9566e3ce83d159b53f6c25d2fcef8a7fd3efa1c0ed1b026b08cca093bd5797dd57d288f22c5a17eb797da885b23fb91f9cda45a9c19f
data/lib/encrypt_env.rb CHANGED
@@ -7,6 +7,7 @@ require 'active_support/core_ext/hash/indifferent_access'
7
7
  require 'tempfile'
8
8
 
9
9
  # gem 'encrypt_env'
10
+ # rubocop: disable all
10
11
  class EncryptEnv
11
12
  private_class_method def self.master_key
12
13
  key = File.read("#{@path_root}/config/master.key")
@@ -17,7 +18,7 @@ class EncryptEnv
17
18
  encrypted = raw_data.slice(0, raw_data.length - 28)
18
19
  iv = raw_data.slice(raw_data.length - 28, 12)
19
20
  tag = raw_data.slice(raw_data.length - 16, 16)
20
- { encrypted: encrypted, iv: iv, tag: tag }
21
+ return { encrypted: encrypted, iv: iv, tag: tag }
21
22
  end
22
23
 
23
24
  private_class_method def self.encrypt(content)
@@ -27,7 +28,6 @@ class EncryptEnv
27
28
  iv = cipher.random_iv
28
29
  encrypted = cipher.update(content) + cipher.final
29
30
  tag = cipher.auth_tag
30
- # rubocop: disable all
31
31
  hex_string = (encrypted + iv + tag).unpack('H*').first
32
32
  File.open("#{@path_root}/config/secrets.yml.enc", 'w') { |file| file.write(hex_string) }
33
33
  end
@@ -36,10 +36,10 @@ class EncryptEnv
36
36
  decipher = OpenSSL::Cipher.new('aes-128-gcm')
37
37
  decipher.decrypt
38
38
  hex_string = File.read("#{@path_root}/config/secrets.yml.enc")
39
- data_decrypt = self.data_decrypt([hex_string].pack('H*'))
40
- decipher.iv = data_decrypt[:iv]
39
+ data = data_decrypt([hex_string].pack('H*'))
40
+ decipher.iv = data[:iv]
41
41
  decipher.key = master_key
42
- decipher.auth_tag = data_decrypt[:tag]
42
+ decipher.auth_tag = data[:tag]
43
43
 
44
44
  decipher.update(data_decrypt[:encrypted]) + decipher.final
45
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: encrypt_env
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nhu Tan