Created
February 22, 2018 21:44
-
-
Save scalone/ba05cdcc3fe2af3b62fc7fecf7f63a89 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Diagnostic | |
class KeyInject | |
FILE = './shared/injected_keys.json' | |
def self.table_exist? | |
File.exists?(FILE) | |
end | |
def self.table | |
self.setup unless @table | |
@table | |
end | |
def self.local | |
self.setup unless @local | |
@local | |
end | |
def self.metadata | |
if self.local | |
# | |
else | |
[] | |
end | |
end | |
def self.setup | |
@local = self.system_check | |
if self.table_exists? | |
@table = JSON.parse(File.read(FILE)) | |
else | |
@table = [] | |
end | |
end | |
def self.system_check | |
(0..100).to_a.inject({}) do |hash, slot| | |
ksn = Device::Pinpad.key_ksn(slot) | |
if (ksn[:pin][0] == 0 || ksn[:data][0] == 0) | |
hash[slot] = (ksn[:pin][1] || ksn[:data][1]) | |
end | |
hash | |
end | |
end | |
end | |
end | |
#... Handshake class | |
def injected_keys | |
Diagnostic::KeyInject.local.inject([]) do |array, key| | |
acquirer = Diagnostic::KeyInject.table.find {|row| row["ksi"] == hash[key[1]][0..9]} | |
hash[i.to_s.rjust(2,'0')] = data[0].to_s + " " + data[1].to_s | |
array << {key[0] => "#{acquirer["acquirer_name"]} #{acquirer["type"]}"} | |
end.to_ | |
end | |
#... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment