X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/a71c68bdf0d117609a1ffd0141d1d682e1ff8e15..1c59e80aba9067335bef60222c6ebbd98fba8c44:/client/lualibs/utils.lua?ds=sidebyside

diff --git a/client/lualibs/utils.lua b/client/lualibs/utils.lua
index 698017d9..39f8bca2 100644
--- a/client/lualibs/utils.lua
+++ b/client/lualibs/utils.lua
@@ -75,13 +75,27 @@ 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-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
+		if  type(s) == 'string' then
+			local utils = require('utils')
+			local asc = utils.ConvertHexToAscii(s)
+			local hash = core.crc8legic(asc)
+			return hash
+		end
+		return nil
+	end,
+	
 	------------ CRC-16 ccitt checksums
 	-- Takes a hex string and calculates a crc16
 	Crc16 = function(s)
@@ -96,6 +110,7 @@ local Utils =
 		return nil
 	end,
 	
+	
 	------------ CRC-64 ecma checksums
 	-- Takes a hex string and calculates a crc64 ecma
 	Crc64 = function(s)
@@ -286,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)