X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/a75d63f19b93f22faeff886f9f2568f3d7531d55..c48211f7ed175c91d92044e7e08b921e06f8ff3f:/client/lualibs/utils.lua diff --git a/client/lualibs/utils.lua b/client/lualibs/utils.lua index 399c30ed..39f8bca2 100644 --- a/client/lualibs/utils.lua +++ b/client/lualibs/utils.lua @@ -75,15 +75,15 @@ local Utils = if #s == 0 then return nil end if type(s) == 'string' then local utils = require('utils') - local ascii = utils.ConvertHexToAscii(s) - local hashed = core.iso14443b_crc(ascii) - return utils.ConvertAsciiToHex(hashed) + return utils.ConvertAsciiToHex( + core.iso14443b_crc(s) + ) end return nil end, - ------------ CRC-16 ccitt checksums - -- Takes a hex string and calculates a crc16 + ------------ CRC-8 Legic checksums + -- Takes a hex string and calculates a crc8 Crc8Legic = function(s) if s == nil then return nil end if #s == 0 then return nil end @@ -301,6 +301,15 @@ local Utils = return n end, + -- a simple implementation of a sleep command. Thanks to Mosci + -- takes number of seconds to sleep + Sleep = function(n) + local clock = os.clock + local t0 = clock() + while clock() - t0 <= n do end + return nil + end, + -- function convertStringToBytes(str) -- local bytes = {} -- local strLength = string.len(str)