docintegritycheck 0.0.1
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 +7 -0
- data/lib/doc_integrity_check.rb +6 -0
- data/lib/encrypt_decrypt.rb +16 -0
- data/lib/hash_verify.rb +16 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4149f3db2a8eee71707d131f858eb29bd1786044
|
4
|
+
data.tar.gz: fcda543e52adcc07dc828e23fbd73df0ed864941
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6b7aa427c0e865e7c15c75053cd6d49a8c815ff9f7b305f04b44aaa5196e7f273673e9519ce693b032629ded355d375b64c5838696bf981ee2841d5362e89063
|
7
|
+
data.tar.gz: b1daf2843177a99a85edbe73b4a54eba5c51458b7f4761bbfbf792088a02f4f4d9f7711ffc213762cb94f0c62871d4089941f8a9b3817690d98ea08a34f2c1f0
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "gpgme"
|
2
|
+
|
3
|
+
# Handles encryption and decryption of files
|
4
|
+
module EncryptDecrypt
|
5
|
+
# Encrypt file
|
6
|
+
def encrypt_data(file_obj, recipient)
|
7
|
+
crypto = GPGME::Crypto.new
|
8
|
+
return crypto.encrypt(file_obj, recipients: recipient, armor: true)
|
9
|
+
end
|
10
|
+
|
11
|
+
# Decrypt data
|
12
|
+
def decrypt(data)
|
13
|
+
crypto = GPGME::Crypto.new
|
14
|
+
return crypto.decrypt(data).to_s
|
15
|
+
end
|
16
|
+
end
|
data/lib/hash_verify.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "digest"
|
2
|
+
require "pry"
|
3
|
+
|
4
|
+
module HashVerify
|
5
|
+
# Hash file object
|
6
|
+
def hash_file(encrypted_file_obj)
|
7
|
+
Digest::SHA256.hexdigest(encrypted_file_obj.to_s)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Verify the hash to a file
|
11
|
+
def hash_verified?(file_details)
|
12
|
+
hash = file_details["file_hash"]
|
13
|
+
rechecked_hash = hash_file(file_details[:encrypted_text])
|
14
|
+
return hash == rechecked_hash
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: docintegritycheck
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- M. C. McGrath
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-02-25 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Encrypts, verifies, and checks hashes of files
|
14
|
+
email: shidash@transparencytoolkit.org
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/doc_integrity_check.rb
|
20
|
+
- lib/encrypt_decrypt.rb
|
21
|
+
- lib/hash_verify.rb
|
22
|
+
homepage: https://github.com/TransparencyToolkit/DocIntegrityCheck
|
23
|
+
licenses:
|
24
|
+
- GPL
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.6.11
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: Checks the integrity of files
|
46
|
+
test_files: []
|