Skip to content

Instantly share code, notes, and snippets.

@neuro-sys neuro-sys/LRC.java
Last active Jul 18, 2018

Embed
What would you like to do?
Longitudinal Redundancy Check (LRC) calculator for a byte array.
public class LRC {
public static byte calculateLRC(byte[] bytes) {
byte LRC = 0;
for (int i = 0; i < bytes.length; i++) {
LRC ^= bytes[i];
}
return LRC;
}
}
@kiseiju

This comment has been minimized.

Copy link

commented Oct 8, 2013

Should it be
for (int i = 0; i < bytes.length - 1; i++),
start from 0 ?

@neuro-sys

This comment has been minimized.

Copy link
Owner Author

commented Jan 23, 2015

Indeed, kiseju. Updated.

@miikeFuhrer

This comment has been minimized.

Copy link

commented Dec 13, 2017

I updated to:
for (int i = 1; i < bytes.length; i++)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.