Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. public class CRC {
  2. public CRC() {}
  3.  
  4. public static byte CRC8(byte[] bytes){
  5. byte generator = (byte) 0x07;
  6. byte crc = 0;
  7.  
  8. for(byte currByte : bytes){
  9. crc ^= currByte;
  10.  
  11. for (int i = 0; i < 8; i++){
  12. if ((crc & 0x80) != 0){
  13. crc = (byte)((crc << 1) ^ generator);
  14. }
  15. else {
  16. crc <<= 1;
  17. }
  18. }
  19. }
  20. return crc;
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement