hash_comparator 0.0.3 → 0.0.4

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: 54c03d1e58cabe164b3df964dac46cee9f437b0071c0e0f5fca0a05f2188d49e
4
- data.tar.gz: f9d2999965d9b2588f4ebb90b389596e34c2435f97bb17517300b938caf28209
3
+ metadata.gz: 550a7997f98003e8493e13f2d57e532e1e25d337b071b9d1123142e946b3287e
4
+ data.tar.gz: d3f25227b786f9dfa2a14d313a46fe893a8590f875c6b063638fadc76b7278e4
5
5
  SHA512:
6
- metadata.gz: 8449d47c0c12cc89e2fbb3827790a6103d81d2b2f5b64b863840a284243f13622f24b69e621153970942289b348a186f12f8578f1d3543aa89773cc9baf2814a
7
- data.tar.gz: 7688d1f04f962e17aaea4c6591899627432842dec49e3e62ac47bd652c2a550c37b9b08fa755de973e6a55f4e2001e41b85dcc72b2a352961af3d918b1afedf2
6
+ metadata.gz: 063b599214283153a2fe2ab912a956426ccecabe943a74cd1727d5309c3440a737c93c5e10a188761bf11f5b09cb5c0c5a7db3d98d1c0b688085a611b2ca65c9
7
+ data.tar.gz: 0fe9b548064a7065108a14a43acfe1f086be64568a2323b8c0a6b82feb9ae6735389294fad70ac69aa9b5dbd7110a2d449a6a24038c1dc1cd6d3e634ff8671dd
@@ -6,35 +6,44 @@ require 'hash_comparator/reverse_matcher'
6
6
  module HashComparator
7
7
  module Emails
8
8
  class Analyzer
9
- def self.find_common_human_readable(hash_function:, subject_raw_emails:, target_hashed_emails:, options: {})
9
+ def self.find_common_plaintext(hash_function:, subject_plaintext_emails:, target_hashed_emails:, options: {})
10
10
  new(
11
11
  hash_function: hash_function,
12
- subject_raw_emails: subject_raw_emails,
12
+ subject_plaintext_emails: subject_plaintext_emails,
13
13
  target_hashed_emails: target_hashed_emails,
14
14
  options: options
15
- ).find_common_human_readable
15
+ ).find_common_plaintext
16
16
  end
17
17
 
18
- def self.find_common_hashes(hash_function:, subject_raw_emails:, target_hashed_emails:, options: {})
18
+ def self.find_common_hashes(hash_function:, subject_plaintext_emails:, target_hashed_emails:, options: {})
19
19
  new(
20
20
  hash_function: hash_function,
21
- subject_raw_emails: subject_raw_emails,
21
+ subject_plaintext_emails: subject_plaintext_emails,
22
22
  target_hashed_emails: target_hashed_emails,
23
23
  options: options
24
24
  ).find_common_hashes
25
25
  end
26
26
 
27
- def initialize(hash_function:, subject_raw_emails:, target_hashed_emails:, options:)
27
+ def self.find_full_results(hash_function:, subject_plaintext_emails:, target_hashed_emails:, options: {})
28
+ new(
29
+ hash_function: hash_function,
30
+ subject_plaintext_emails: subject_plaintext_emails,
31
+ target_hashed_emails: target_hashed_emails,
32
+ options: options
33
+ ).find_full_results
34
+ end
35
+
36
+ def initialize(hash_function:, subject_plaintext_emails:, target_hashed_emails:, options:)
28
37
  @hash_function = hash_function
29
- @subject_raw_emails = subject_raw_emails
38
+ @subject_plaintext_emails = subject_plaintext_emails
30
39
  @target_hashed_emails = target_hashed_emails
31
40
  @options = options
32
41
  @subject_hashed_emails = []
33
42
  end
34
43
 
35
- attr_accessor :hash_function, :subject_raw_emails, :subject_hashed_emails, :target_hashed_emails, :options
44
+ attr_accessor :hash_function, :subject_plaintext_emails, :subject_hashed_emails, :target_hashed_emails, :options
36
45
 
37
- def find_common_human_readable
46
+ def find_common_plaintext
38
47
  common_hashes = find_common_hashes
39
48
  reverse_match(common_hashes)
40
49
  end
@@ -45,18 +54,24 @@ module HashComparator
45
54
  compare
46
55
  end
47
56
 
57
+ def find_full_results
58
+ common_hashed_emails = find_common_hashes
59
+ common_plaintext_emails = reverse_match(common_hashed_emails)
60
+ { common_hashed_emails: common_hashed_emails, common_plaintext_emails: common_plaintext_emails }
61
+ end
62
+
48
63
  private
49
64
 
50
65
  def parse
51
66
  if options[:parsing]
52
- @subject_raw_emails = Parser.parse(subject_raw_emails, options[:parsing])
67
+ @subject_plaintext_emails = Parser.parse(subject_plaintext_emails, options[:parsing])
53
68
  end
54
69
  end
55
70
 
56
71
  def hash
57
72
  @subject_hashed_emails = Hasher.hash(
58
73
  hash_function: hash_function,
59
- human_readable_items: subject_raw_emails
74
+ plaintext_items: subject_plaintext_emails
60
75
  )
61
76
  end
62
77
 
@@ -71,7 +86,7 @@ module HashComparator
71
86
  ReverseMatcher.execute(
72
87
  hash_function: hash_function,
73
88
  hashed_items: common_hashes,
74
- human_readable_items: subject_raw_emails
89
+ plaintext_items: subject_plaintext_emails
75
90
  )
76
91
  end
77
92
  end
@@ -9,19 +9,19 @@ module HashComparator
9
9
  sha512: Digest::SHA512
10
10
  }.freeze
11
11
 
12
- def self.hash(hash_function:, human_readable_items:)
13
- new(hash_function: hash_function, human_readable_items: human_readable_items).hash
12
+ def self.hash(hash_function:, plaintext_items:)
13
+ new(hash_function: hash_function, plaintext_items: plaintext_items).hash
14
14
  end
15
15
 
16
- def initialize(hash_function:, human_readable_items:)
16
+ def initialize(hash_function:, plaintext_items:)
17
17
  @hash_function = SUPPORTED_HASH_FUNCTIONS[hash_function]
18
- @human_readable_items = human_readable_items
18
+ @plaintext_items = plaintext_items
19
19
  end
20
20
 
21
- attr_accessor :hash_function, :human_readable_items
21
+ attr_accessor :hash_function, :plaintext_items
22
22
 
23
23
  def hash
24
- human_readable_items.map do |item|
24
+ plaintext_items.map do |item|
25
25
  hash_function.hexdigest(item)
26
26
  end
27
27
  end
@@ -3,29 +3,29 @@ require 'hash_comparator/hasher'
3
3
 
4
4
  module HashComparator
5
5
  class ReverseMatcher
6
- def self.execute(hash_function:, hashed_items:, human_readable_items:)
6
+ def self.execute(hash_function:, hashed_items:, plaintext_items:)
7
7
  new(
8
8
  hash_function: hash_function,
9
9
  hashed_items: hashed_items,
10
- human_readable_items: human_readable_items
10
+ plaintext_items: plaintext_items
11
11
  ).execute
12
12
  end
13
13
 
14
- def initialize(hash_function:, hashed_items:, human_readable_items:)
14
+ def initialize(hash_function:, hashed_items:, plaintext_items:)
15
15
  @hash_function = hash_function
16
- @human_readable_items = human_readable_items
16
+ @plaintext_items = plaintext_items
17
17
  @hashed_items = hashed_items
18
18
  end
19
19
 
20
- attr_accessor :hash_function, :human_readable_items, :hashed_items
20
+ attr_accessor :hash_function, :plaintext_items, :hashed_items
21
21
 
22
22
  def execute
23
23
  subject_hashed_items = Hasher.hash(
24
24
  hash_function: hash_function,
25
- human_readable_items: human_readable_items
25
+ plaintext_items: plaintext_items
26
26
  )
27
27
 
28
- matches = human_readable_items.each_with_index.each_with_object([]) do |(item, i), list|
28
+ matches = plaintext_items.each_with_index.each_with_object([]) do |(item, i), list|
29
29
  list << item if hashed_items.include?(subject_hashed_items[i])
30
30
  end
31
31
 
@@ -1,3 +1,3 @@
1
1
  module HashComparator
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash_comparator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tanner Johnson