Last active
February 23, 2018 17:44
-
-
Save scalone/06de26d3dfdb14932ade4116b2ae7f85 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"] == key[1][0..9]} | |
array << {key[0] => "#{acquirer["acquirer_name"]} #{acquirer["type"]}"} | |
end.to_json | |
end | |
#... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment