X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/9ccfb3a8bcadeba557c285783f8ebbe2cde5fd3b..867e10a5fdf0d26c8ee63735b894e7d3953ebbb2:/client/lualibs/utils.lua diff --git a/client/lualibs/utils.lua b/client/lualibs/utils.lua index a968fde2..592d0477 100644 --- a/client/lualibs/utils.lua +++ b/client/lualibs/utils.lua @@ -99,6 +99,32 @@ local Utils = end return nil end, + + ------------ SHA1 hash + -- Takes a string and calculates a SHA1 hash + Sha1 = 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.sha1(s) + return hash + end + return nil + end, + -- Takes a hex string and calculates a SHA1 hash + Sha1Hex = 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.sha1(asc) + return hash + end + return nil + end, -- input parameter is a string @@ -288,4 +314,4 @@ local Utils = -- end } -return Utils \ No newline at end of file +return Utils