mirror of
https://github.com/Djeeberjr/fw-anwesenheit.git
synced 2025-10-13 15:06:39 +00:00
added pm3 write script & already used ids
This commit is contained in:
parent
4ff8ff0f77
commit
2a81499f7c
61
em4100_write.lua
Normal file
61
em4100_write.lua
Normal file
@ -0,0 +1,61 @@
|
||||
local used_ids = {}
|
||||
local id_file_path = "used_ids.txt"
|
||||
|
||||
local function load_ids()
|
||||
local file = io.open(id_file_path, "r")
|
||||
if not file then return end
|
||||
for line in file:lines() do
|
||||
used_ids[line:lower()] = true
|
||||
end
|
||||
file:close()
|
||||
end
|
||||
|
||||
local function save_id(id)
|
||||
local file = io.open(id_file_path, "a")
|
||||
if file then
|
||||
file:write(id:lower() .. "\n")
|
||||
file:close()
|
||||
end
|
||||
end
|
||||
|
||||
local function gen_id()
|
||||
local id = ""
|
||||
for i = 1, 10 do
|
||||
id = id .. string.format("%x", math.random(0, 15))
|
||||
end
|
||||
return id
|
||||
end
|
||||
|
||||
local function get_new_id()
|
||||
local tries = 0
|
||||
while tries < 10000 do
|
||||
local id = gen_id()
|
||||
if not used_ids[id:lower()] then
|
||||
return id
|
||||
end
|
||||
tries = tries + 1
|
||||
end
|
||||
error("Could not generate a new unused ID after 10000 tries")
|
||||
end
|
||||
|
||||
local function write_new_card()
|
||||
local id = get_new_id()
|
||||
local cmd = string.format("lf em 410x clone --id %s", id)
|
||||
core.console(cmd)
|
||||
used_ids[id:lower()] = true
|
||||
save_id(id)
|
||||
print("Wrote new EM4100 card with ID:", id)
|
||||
end
|
||||
|
||||
local function write_new_card(id)
|
||||
local cmd = string.format("lf em 410x clone --id %s", id)
|
||||
core.console(cmd)
|
||||
used_ids[id:lower()] = true
|
||||
save_id(id)
|
||||
print("Wrote new EM4100 card with ID:", id)
|
||||
end
|
||||
|
||||
math.randomseed(os.time())
|
||||
load_ids()
|
||||
local id = get_new_id()
|
||||
write_new_card(id)
|
88
used_ids.txt
Normal file
88
used_ids.txt
Normal file
@ -0,0 +1,88 @@
|
||||
8f801f988c
|
||||
6fc90dd450
|
||||
edf3f0793a
|
||||
df39cf9566
|
||||
b9f998924d
|
||||
f7686ed090
|
||||
c4dc09d5fa
|
||||
78908e3baa
|
||||
da874600cd
|
||||
66beb3dfad
|
||||
b5758c2ada
|
||||
aee543f099
|
||||
ea912de917
|
||||
d309e7a0da
|
||||
54d1fbd27a
|
||||
a2f95c6f50
|
||||
b663118bfd
|
||||
8d639f381c
|
||||
25ec58dace
|
||||
a0ecef7443
|
||||
cab4672699
|
||||
f8a021b691
|
||||
5314cc63d8
|
||||
ad4a8a3882
|
||||
927ead1dec
|
||||
743a8e8162
|
||||
f54694666a
|
||||
38f8ff49c4
|
||||
6da025be13
|
||||
afe671009f
|
||||
8a18526cc5
|
||||
fe6ead39e7
|
||||
07b0391c5b
|
||||
aaf6d9cef5
|
||||
ee12fe5bbf
|
||||
96b833ccc2
|
||||
690eec798e
|
||||
142c3cb709
|
||||
cc585eea85
|
||||
1b426bf077
|
||||
3df69e83bc
|
||||
8fba107bbc
|
||||
79e24823d2
|
||||
3ec6e52678
|
||||
e1e0d87659
|
||||
4c12460af8
|
||||
7d506534de
|
||||
c4946d9a72
|
||||
80d2b13291
|
||||
0c36d4a7a7
|
||||
776cef50a2
|
||||
1cc64b5158
|
||||
ee78890172
|
||||
63fa57ad63
|
||||
9072b8fad8
|
||||
b3c407a858
|
||||
833c54a7a5
|
||||
99d2c32c35
|
||||
4f5e5357e2
|
||||
82cea5924d
|
||||
fec8fa57ef
|
||||
11b49b1b2b
|
||||
e40a8e6e3f
|
||||
2fbe63bb85
|
||||
f76830b226
|
||||
76544233e5
|
||||
2fc8c544ef
|
||||
2a4cc77d6b
|
||||
f52eebdd85
|
||||
508e07aca5
|
||||
936aed7997
|
||||
0fbf70c4c6
|
||||
bf47dfd6b7
|
||||
81e7d42454
|
||||
96b701ef5d
|
||||
11d3ecfa1b
|
||||
e0bd39c427
|
||||
6fa914114e
|
||||
d7a3b89055
|
||||
e417131533
|
||||
1fef16c2ce
|
||||
1af12ecd77
|
||||
37e1a8f1dc
|
||||
65e4521004
|
||||
a0be6cc4fa
|
||||
90bcf9dbaa
|
||||
8f169642c4
|
||||
ac5b109c5b
|
Loading…
x
Reference in New Issue
Block a user