Merge pull request #1134 from tcprst/legic_lua_fix

hf_legic Lua - change method for temp file naming
This commit is contained in:
Iceman 2020-12-23 22:14:42 +01:00 committed by GitHub
commit 7a6d72fcd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -704,12 +704,31 @@ function writeFile(bytes, filename)
return true return true
end end
function getRandomTempName()
local upperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
local lowerCase = "abcdefghijklmnopqrstuvwxyz"
local characterSet = upperCase .. lowerCase
local keyLength = 8
local output = ""
for i = 1, keyLength do
local rand = math.random(#characterSet)
output = output .. string.sub(characterSet, rand, rand)
end
output = "hf-legic-temp-" .. output
return output
end
--- ---
-- read from pm3 into virtual-tag -- read from pm3 into virtual-tag
function readFromPM3() function readFromPM3()
local tag, bytes, infile local tag, bytes, infile
--infile="legic.temp" --infile="legic.temp"
infile=os.tmpname() infile=getRandomTempName()
core.console("hf legic dump -f "..infile) core.console("hf legic dump -f "..infile)
tag=readFile(infile..".bin") tag=readFile(infile..".bin")
os.remove(infile) os.remove(infile)