Skip to content

Instantly share code, notes, and snippets.

@cristobal
Created April 25, 2013 10:27
Show Gist options
  • Select an option

  • Save cristobal/5458842 to your computer and use it in GitHub Desktop.

Select an option

Save cristobal/5458842 to your computer and use it in GitHub Desktop.
Port of php.js bin2hex to lua http://phpjs.org/functions/bin2hex/
function bin2hex (str)
local val = ""
for i = 1, str:len() do
char = string.byte(str:sub(i, i))
val = string.format("%s%02X%s", val, char, "")
end
return val
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment