Instantly share code, notes, and snippets.

@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.

Show comment
Hide comment
@kiseiju

kiseiju Oct 8, 2013

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

kiseiju 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.

Show comment
Hide comment
@neuro-sys

neuro-sys Jan 23, 2015

Indeed, kiseju. Updated.

Owner

neuro-sys commented Jan 23, 2015

Indeed, kiseju. Updated.

@miikeFuhrer

This comment has been minimized.

Show comment
Hide comment
@miikeFuhrer

miikeFuhrer Dec 13, 2017

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

miikeFuhrer 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