Posted By

ukpyr on 03/13/09


Tagged


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

CobaltHex
Tyster


String to HEX


 / Published in: Lua
 

  1. --- Returns HEX representation of str
  2. function str2hex(str)
  3. local hex = ''
  4. while #str > 0 do
  5. local hb = num2hex(string.byte(str, 1, 1))
  6. if #hb < 2 then hb = '0' .. hb end
  7. hex = hex .. hb
  8. str = string.sub(str, 2)
  9. end
  10. return hex
  11. end

Report this snippet  

You need to login to post a comment.