Advertisement
KidBrine

Binary Converter

Apr 19th, 2017
349
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 1 0
  1. function TextBin(ch)
  2. ch = string.byte(ch)
  3. r = ""
  4. local function chn(n)
  5. if ch >= n then
  6. ch = ch-n
  7. r = r..1
  8. else
  9. r = r..0
  10. end
  11. end
  12. chn(128) chn(64) chn(32) chn(16)
  13. chn(8) chn(4) chn(2) chn(1)
  14. chn = nil
  15. return r
  16. end
  17.  
  18. function BinText(n)
  19. r = string.char(tonumber(n,2))
  20. return r
  21. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement