Skip to content

Commit db30e67

Browse files
committed
Store checksum in comitted data
Not currently used, but will be used for verification and protection later
1 parent e454d86 commit db30e67

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/diffcrypt/encryptor.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def encrypt(contents, original_encrypted_contents = nil)
4949
YAML.dump(
5050
'client' => "diffcrypt-#{Diffcrypt::VERSION}",
5151
'cipher' => CIPHER,
52+
'checksum' => Digest::MD5.hexdigest(Marshal.dump(data)),
5253
'data' => data,
5354
)
5455
end

test/diffcrypt/encryptor_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class Diffcrypt::EncryptorTest < Minitest::Test
1111
def test_it_includes_client_info_at_root
1212
content = "---\nkey: value"
13-
expected_pattern = /---\nclient: diffcrypt-#{Diffcrypt::VERSION}\ncipher: #{Diffcrypt::Encryptor::CIPHER}\ndata:\n key: #{ENCRYPTED_VALUE_PATTERN}\n/
13+
expected_pattern = /---\nclient: diffcrypt-#{Diffcrypt::VERSION}\ncipher: #{Diffcrypt::Encryptor::CIPHER}\nchecksum: [a-z0-9]{32}\ndata:\n key: #{ENCRYPTED_VALUE_PATTERN}\n/
1414
assert_match expected_pattern, Diffcrypt::Encryptor.new(TEST_KEY).encrypt(content)
1515
end
1616

0 commit comments

Comments
 (0)