+ -- input parameter is a string\r
+ -- Swaps the endianess and returns a string, \r
+ -- IE: 'cd7a' -> '7acd' -> 0x7acd\r
+ SwapEndiannessStr = function(s, len)\r
+ if s == nil then return nil end\r
+ if #s == 0 then return '' end\r
+ if type(s) ~= 'string' then return nil end\r
+ \r
+ local retval\r
+ if len == 16 then\r
+ retval = s:sub(3,4)..s:sub(1,2)\r
+ elseif len == 24 then\r
+ retval = s:sub(5,6)..s:sub(3,4)..s:sub(1,2)\r
+ elseif len == 32 then\r
+ retval = s:sub(7,8)..s:sub(5,6)..s:sub(3,4)..s:sub(1,2)\r
+ end\r
+ return retval\r
+ end, \r