diffcrypt 0.1.1 → 0.2.0
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/.circleci/config.yml +11 -0
- data/.github/dependabot.yml +7 -0
- data/.rubocop.yml +2 -0
- data/README.md +1 -1
- data/lib/diffcrypt/encryptor.rb +18 -5
- data/lib/diffcrypt/version.rb +1 -1
- metadata +3 -2
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edd41bfcd4f86767e1d8b98d4c161c38983962e273a6e5b486c0f6465f159d80
|
4
|
+
data.tar.gz: fecb2bda4f1f7cbd53fea2fd333f723bd3c1ac9e8c206930c6783795a6260d10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fe1aedc3eec0f98370479a8a813e15a9458213e70d49345ae90234cead04e47b880a602af54ff8d43a1a6e4d54e7bef4a2955eb3f88fde68762bb08de16a555
|
7
|
+
data.tar.gz: 6a020043e24b13d22414de6f810bde69bb578adc0041d34e33c8f3d220d68903ed8b3726bc7302138fbdc00ebfe8c2e7a59bca4e776519a3d898fc4cd4d51845
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -45,7 +45,7 @@ config = YAML.safe_load(encryptor.decrypt(yaml))
|
|
45
45
|
### Rails
|
46
46
|
|
47
47
|
Currently there is not native support for rails, but ActiveSupport can be monkeypatched to override
|
48
|
-
the
|
48
|
+
the built in encrypter.
|
49
49
|
|
50
50
|
```ruby
|
51
51
|
require 'diffcrypt/rails/encrypted_configuration'
|
data/lib/diffcrypt/encryptor.rb
CHANGED
@@ -24,7 +24,7 @@ module Diffcrypt
|
|
24
24
|
# @param [String] contents The raw YAML string to be encrypted
|
25
25
|
def decrypt(contents)
|
26
26
|
yaml = YAML.safe_load contents
|
27
|
-
decrypted = decrypt_hash yaml
|
27
|
+
decrypted = decrypt_hash yaml['data']
|
28
28
|
YAML.dump decrypted
|
29
29
|
end
|
30
30
|
|
@@ -43,11 +43,24 @@ module Diffcrypt
|
|
43
43
|
|
44
44
|
# @param [String] contents The raw YAML string to be encrypted
|
45
45
|
# @param [String, nil] original_encrypted_contents The original (encrypted) content to determine which keys have changed
|
46
|
+
# @return [String]
|
46
47
|
def encrypt(contents, original_encrypted_contents = nil)
|
48
|
+
data = encrypt_data contents, original_encrypted_contents
|
49
|
+
YAML.dump(
|
50
|
+
'client' => "diffcrypt-#{Diffcrypt::VERSION}",
|
51
|
+
'cipher' => CIPHER,
|
52
|
+
'checksum' => Digest::MD5.hexdigest(Marshal.dump(data)),
|
53
|
+
'data' => data,
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
# @param [String] contents The raw YAML string to be encrypted
|
58
|
+
# @param [String, nil] original_encrypted_contents The original (encrypted) content to determine which keys have changed
|
59
|
+
# @return [Hash] Encrypted hash containing the data
|
60
|
+
def encrypt_data(contents, original_encrypted_contents = nil)
|
47
61
|
yaml = YAML.safe_load contents
|
48
|
-
original_yaml = original_encrypted_contents ? YAML.safe_load(original_encrypted_contents) : nil
|
49
|
-
|
50
|
-
YAML.dump encrypted
|
62
|
+
original_yaml = original_encrypted_contents ? YAML.safe_load(original_encrypted_contents)['data'] : nil
|
63
|
+
encrypt_values yaml, original_yaml
|
51
64
|
end
|
52
65
|
|
53
66
|
# @param [String] value Plain text string that needs encrypting
|
@@ -66,7 +79,7 @@ module Diffcrypt
|
|
66
79
|
data[key] = if value.is_a?(Hash) || value.is_a?(Array)
|
67
80
|
encrypt_values(value, original_encrypted_value)
|
68
81
|
else
|
69
|
-
original_decrypted_value =
|
82
|
+
original_decrypted_value = original_encrypted_value ? decrypt_string(original_encrypted_value) : nil
|
70
83
|
key_changed = original_decrypted_value.nil? || original_decrypted_value != value
|
71
84
|
key_changed ? encrypt_string(value) : original_encrypted_value
|
72
85
|
end
|
data/lib/diffcrypt/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diffcrypt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc Qualie
|
@@ -32,9 +32,10 @@ executables: []
|
|
32
32
|
extensions: []
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
|
+
- ".circleci/config.yml"
|
36
|
+
- ".github/dependabot.yml"
|
35
37
|
- ".gitignore"
|
36
38
|
- ".rubocop.yml"
|
37
|
-
- ".travis.yml"
|
38
39
|
- Gemfile
|
39
40
|
- LICENSE.txt
|
40
41
|
- README.md
|