mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
FIX: I think the dumping of data is correct now in tnp3.lua. MD5 string vs bytearrays in lua are tricky
ADD: utils.lua some functions to convert between ascii, bytes and strings.
This commit is contained in:
parent
22f1c57786
commit
cd5767d43d
2 changed files with 46 additions and 25 deletions
|
@ -46,21 +46,46 @@ local Utils =
|
|||
end,
|
||||
---
|
||||
-- Convert Byte array to string of hex
|
||||
ConvertBytes2String = function(bytes)
|
||||
local s = {}
|
||||
ConvertBytes2HexString = function(bytes)
|
||||
if #bytes == 0 then
|
||||
return ''
|
||||
end
|
||||
local s={}
|
||||
for i = 1, #(bytes) do
|
||||
s[i] = string.format("%02X",bytes[i])
|
||||
end
|
||||
return table.concat(s)
|
||||
end,
|
||||
|
||||
ConvertStringToBytes = function(s)
|
||||
-- Convert byte array to string with ascii
|
||||
ConvertBytesToAsciiString = function(bytes)
|
||||
if #bytes == 0 then
|
||||
return ''
|
||||
end
|
||||
local s={}
|
||||
for i = 1, #(bytes) do
|
||||
s[i] = string.char(bytes[i])
|
||||
end
|
||||
return table.concat(s)
|
||||
end,
|
||||
ConvertHexStringToBytes = function(s)
|
||||
local t={}
|
||||
if s == nil then return t end
|
||||
if #s == 0 then return t end
|
||||
for k in s:gmatch"(%x%x)" do
|
||||
table.insert(t,tonumber(k,16))
|
||||
end
|
||||
return t
|
||||
end,
|
||||
ConvertAsciiStringToBytes = function(s)
|
||||
local t={}
|
||||
if s == nil then return t end
|
||||
if #s == 0 then return t end
|
||||
|
||||
for k in s:gmatch"(.)" do
|
||||
table.insert(t, string.byte(k))
|
||||
end
|
||||
return t
|
||||
end,
|
||||
|
||||
-- function convertStringToBytes(str)
|
||||
-- local bytes = {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue