Advertisement
Guest User

RBX Lua String to Binary!

a guest
Oct 8th, 2015
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. binaryt = {
  2. {'a',01000001};{'b',01000010};{'c',01000011};{'d',01000100};{'e',01000101};
  3. {'f',01000110};{'g',01000111};{'h',01001000};{'i',01001001};{'j',01001010};
  4. {'k',01001011};{'l',01001100};{'m',01001101};{'n',01001110};{'o',01001111};
  5. {'p',01010000};{'q',01010001};{'r',01010010};{'s',01010011};{'t',01010100};
  6. {'u',01010101};{'v',01010110};{'w',01010111};{'x',01011000};{'y',01011001};
  7. {'z',01011010};{' ',00000000}}
  8.  
  9. _G.strtobinary = function(str,spc,con)
  10. local numbers = ''
  11. for i = 1, string.len(str) do
  12. for _,v in pairs (binaryt) do
  13. if v[1] == string.sub(str,i,i) then
  14. numbers = numbers..v[2]+100000
  15. elseif v[1] == string.sub(str:lower(),i,i) then
  16. numbers = numbers..v[2]
  17. end
  18. end
  19. if con then
  20. numbers = numbers..': '..string.sub(str,i,i)
  21. end
  22. if spc then
  23. numbers = numbers..' '
  24. end
  25. end
  26. return numbers
  27. end
  28.  
  29. str = _G.strtobinary(
  30. 'stringhere', --string that your converting
  31. false, -- true puts spaces between binary code. EX: 01000011 01000010
  32. false) -- true puts letter after the binary code. EX: 01000010:b
  33. print(str)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement