]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/lualibs/utils.lua
Do not treat gcc's "misleading-indentation" warning as error (fixes #187).
[proxmark3-svn] / client / lualibs / utils.lua
index a968fde2a90c3b2218b6e67aa005bdeec7486db6..592d0477d9f1ead73a754860e218e4d8ba2eb77d 100644 (file)
@@ -99,6 +99,32 @@ local Utils =
                end\r
                return nil\r
        end,\r
+\r
+       ------------ SHA1 hash\r
+       -- Takes a string and calculates a SHA1 hash\r
+       Sha1 = 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.sha1(s)\r
+                       return hash\r
+               end\r
+               return nil\r
+       end,\r
+       -- Takes a hex string and calculates a SHA1 hash\r
+       Sha1Hex = 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.sha1(asc)\r
+                       return hash\r
+               end\r
+               return nil\r
+       end,\r
        \r
        \r
        -- input parameter is a string\r
@@ -288,4 +314,4 @@ local Utils =
 -- end\r
 \r
 }\r
-return Utils
\ No newline at end of file
+return Utils\r
Impressum, Datenschutz