Created
July 19, 2015 14:01
-
-
Save Moligaloo/775202cb5b5c13bbf128 to your computer and use it in GitHub Desktop.
Convert lua function to hexadecimal string format and back
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function func2hex(func) | |
return (string.dump(func):gsub(".", function(c) return ("%02X"):format(c:byte()) end)); | |
end | |
function hex2func(hex) | |
return loadstring(hex:gsub("..", function(x) return string.char(tonumber(x, 16)) end)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment