X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/02d352fea75385d80b49a7ab8703692ae307f073..553e868f250528a1dd687f2ec5232b9f6336daa1:/client/lualibs/utils.lua diff --git a/client/lualibs/utils.lua b/client/lualibs/utils.lua index a968fde2..da179758 100644 --- a/client/lualibs/utils.lua +++ b/client/lualibs/utils.lua @@ -37,9 +37,7 @@ local Utils = ------------ FILE READING ReadDumpFile = function (filename) - if filename == nil then - return nil, 'Filename is empty' - end + filename = filename or 'dumpdata.bin' if #filename == 0 then return nil, 'Filename length is zero' end @@ -99,7 +97,33 @@ 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 -- Swaps the endianess and returns a number,