mfkeys.lua: Remove trailing whitespaces.

This commit is contained in:
Arnie97 2018-01-25 14:48:26 +08:00
commit b5cf8b07e2

View file

@ -90,9 +90,10 @@ local function displayresults(results)
print("|--------------------------------------|") print("|--------------------------------------|")
end end
-- A little helper to place an item first in the list -- A little helper to place an item first in the list
local function placeFirst(akey, list) local function placeFirst(akey, list)
akey = akey:lower() akey = akey:lower()
if list[1] == akey then if list[1] == akey then
-- Already at pole position -- Already at pole position
return list return list
@ -106,6 +107,7 @@ local function placeFirst(akey, list)
end end
return result return result
end end
local function dumptofile(results) local function dumptofile(results)
local sector, blockNo, keyA, keyB,_ local sector, blockNo, keyA, keyB,_
@ -132,7 +134,7 @@ local function dumptofile(results)
end end
local function main( args) local function main(args)
print(desc); print(desc);
@ -149,7 +151,7 @@ local function main( args)
local keyType = 0 -- A=0, B=1 local keyType = 0 -- A=0, B=1
local numSectors = 16 local numSectors = 16
if 0x18 == result.sak then --NXP MIFARE Classic 4k | Plus 4k if 0x18 == result.sak then -- NXP MIFARE Classic 4k | Plus 4k
-- IFARE Classic 4K offers 4096 bytes split into forty sectors, -- IFARE Classic 4K offers 4096 bytes split into forty sectors,
-- of which 32 are same size as in the 1K with eight more that are quadruple size sectors. -- of which 32 are same size as in the 1K with eight more that are quadruple size sectors.
numSectors = 40 numSectors = 40
@ -159,7 +161,7 @@ local function main( args)
elseif 0x09 == result.sak then -- NXP MIFARE Mini 0.3k elseif 0x09 == result.sak then -- NXP MIFARE Mini 0.3k
-- MIFARE Classic mini offers 320 bytes split into five sectors. -- MIFARE Classic mini offers 320 bytes split into five sectors.
numSectors = 5 numSectors = 5
elseif 0x10 == result.sak then-- "NXP MIFARE Plus 2k" elseif 0x10 == result.sak then -- NXP MIFARE Plus 2k
numSectors = 32 numSectors = 32
else else
print("I don't know how many sectors there are on this type of card, defaulting to 16") print("I don't know how many sectors there are on this type of card, defaulting to 16")
@ -173,21 +175,21 @@ local function main( args)
The first 32 sectors of a mifare Classic 4k card consists of 4 data blocks and the remaining The first 32 sectors of a mifare Classic 4k card consists of 4 data blocks and the remaining
8 sectors consist of 16 data blocks. 8 sectors consist of 16 data blocks.
--]] --]]
local blockNo = sector * 4 -1 local blockNo = sector * 4 - 1
if sector > 32 then if sector > 32 then
blockNo = 32*4+ (sector-32)*16 -1 blockNo = 32*4 + (sector-32)*16 - 1
end end
local keyA = checkBlock(blockNo, keys, 0) local keyA = checkBlock(blockNo, keys, 0)
if keyA then keys = placeFirst(keyA, keys) end if keyA then keys = placeFirst(keyA, keys) end
keyA = keyA or "" keyA = keyA or ""
local keyB = checkBlock(blockNo, keys, 1) local keyB = checkBlock(blockNo, keys, 1)
if keyB then keys = placeFirst(keyB, keys) end if keyB then keys = placeFirst(keyB, keys) end
keyB = keyB or "" keyB = keyB or ""
result[sector] = {blockNo, keyA, keyB } result[sector] = {blockNo, keyA, keyB}
-- Check if user aborted -- Check if user aborted
if core.ukbhit() then if core.ukbhit() then
@ -199,5 +201,4 @@ local function main( args)
dumptofile(result) dumptofile(result)
end end
main( args) main(args)