Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save czlc/2bde21c7b17d66ecd03b7ca4d67267c9 to your computer and use it in GitHub Desktop.
Save czlc/2bde21c7b17d66ecd03b7ca4d67267c9 to your computer and use it in GitHub Desktop.

Revisions

  1. @yi yi created this gist Jul 24, 2014.
    11 changes: 11 additions & 0 deletions gistfile1.lua
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    function string.fromhex(str)
    return (str:gsub('..', function (cc)
    return string.char(tonumber(cc, 16))
    end))
    end

    function string.tohex(str)
    return (str:gsub('.', function (c)
    return string.format('%02X', string.byte(c))
    end))
    end