]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/lualibs/utils.lua
ADD: added the crc8legic to Lua. call it with core.crc8legic
[proxmark3-svn] / client / lualibs / utils.lua
index 698017d923d28de50a5baa044d7eb51510b1699a..399c30ed5fdb564823d368d44324ebe572a13df5 100644 (file)
@@ -82,6 +82,20 @@ local Utils =
                return nil              \r
        end,\r
        \r
+       ------------ CRC-16 ccitt checksums\r
+       -- Takes a hex string and calculates a crc16\r
+       Crc8Legic = function(s)\r
+               if s == nil then return nil end\r
+               if #s == 0 then return nil end\r
+               if  type(s) == 'string' then\r
+                       local utils = require('utils')\r
+                       local asc = utils.ConvertHexToAscii(s)\r
+                       local hash = core.crc8legic(asc)\r
+                       return hash\r
+               end\r
+               return nil\r
+       end,\r
+       \r
        ------------ CRC-16 ccitt checksums\r
        -- Takes a hex string and calculates a crc16\r
        Crc16 = function(s)\r
@@ -96,6 +110,7 @@ local Utils =
                return nil\r
        end,\r
        \r
+       \r
        ------------ CRC-64 ecma checksums\r
        -- Takes a hex string and calculates a crc64 ecma\r
        Crc64 = function(s)\r
Impressum, Datenschutz