Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.67 KB | None | 0 0
  1. --[[
  2. Checkusm calcluation. Enter the command into the command string below, but do no inlcude the start byte, checksum, or end byte. The result will be printed below.
  3. --]]
  4.  
  5. command = "\x01\x76\x1a\x01"
  6.  
  7.  
  8.  
  9.  
  10. local output, checksum, finish, readable = "\xfe", 0, "\xff", ""
  11. for c in command:gmatch(".") do
  12.   checksum = checksum + string.byte(c)
  13.   output = output .. c
  14. end
  15.  
  16. checksum = checksum % 255
  17.  
  18. output = output .. string.char(checksum) .. finish
  19.  
  20. for c in output:gmatch(".") do
  21.   readable = readable .. string.format("\\x%02x", string.byte(c))
  22. end
  23.  
  24.  
  25.  
  26.  
  27. print(string.format("Checksum: %02x\r\nString for command button: \"%s\"", string.byte(checksum), readable))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement