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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9a07ad0aa1385421550a40093fe6e724337f7697e71f7af081a7011daa05a8c
4
- data.tar.gz: 40406c43e1a8ef7396577e70d62e3bee026db6500563e56aadf113b95203069d
3
+ metadata.gz: edd41bfcd4f86767e1d8b98d4c161c38983962e273a6e5b486c0f6465f159d80
4
+ data.tar.gz: fecb2bda4f1f7cbd53fea2fd333f723bd3c1ac9e8c206930c6783795a6260d10
5
5
  SHA512:
6
- metadata.gz: b3f03e909e4b49740dfd7e6e8e4bdab3a39decca30556149e4645f2071156b9632e3a54827f33fc6fcac7a419443eb066bf8fca249eca98219a9be5989ef3840
7
- data.tar.gz: 001bf874603205e1421a0a99ac8d2c14e15b187495505adb1141f84108b0270d159f58c703c730fea6d69a974b1c8e32b2268437a93b590a9adf8d851f854a37
6
+ metadata.gz: 7fe1aedc3eec0f98370479a8a813e15a9458213e70d49345ae90234cead04e47b880a602af54ff8d43a1a6e4d54e7bef4a2955eb3f88fde68762bb08de16a555
7
+ data.tar.gz: 6a020043e24b13d22414de6f810bde69bb578adc0041d34e33c8f3d220d68903ed8b3726bc7302138fbdc00ebfe8c2e7a59bca4e776519a3d898fc4cd4d51845
@@ -0,0 +1,11 @@
1
+ version: 2.1
2
+
3
+ jobs:
4
+ build:
5
+ docker:
6
+ - image: circleci/ruby:2.6.6
7
+ steps:
8
+ - checkout
9
+ - run: bundle install
10
+ - run: bundle exec rake test
11
+ - run: bundle exec rubocop
@@ -0,0 +1,7 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ rebase-strategy: auto
6
+ schedule:
7
+ interval: daily
@@ -9,6 +9,8 @@ Style/Documentation:
9
9
  Metrics/MethodLength:
10
10
  Exclude:
11
11
  - test/**/*_test.rb
12
+ Style/TrailingCommaInArguments:
13
+ EnforcedStyleForMultiline: consistent_comma
12
14
 
13
15
  Layout/LineLength:
14
16
  Exclude:
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 build in encrypter.
48
+ the built in encrypter.
49
49
 
50
50
  ```ruby
51
51
  require 'diffcrypt/rails/encrypted_configuration'
@@ -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
- encrypted = encrypt_values yaml, original_yaml
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 = original_data ? decrypt_string(original_encrypted_value) : nil
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Diffcrypt
4
- VERSION = '0.1.1'
4
+ VERSION = '0.2.0'
5
5
  end
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.1.1
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
@@ -1,6 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.6.6
6
- before_install: gem install bundler -v 2.1.4