Using XOR for checksums

I have not found much on the use of XOR on the forums, so I decided to make a short demo sketch with an explanation of how it works with checksums.

The history is, that about 15 years ago I wrote some programs to receive serial data from GPS and AIS receivers for use with an old Mac Book Pro on my sailing boat.

I thought it was going to be complex, how wrong I was.

So I have uploaded a simple guide to how XOR checksums work to my Github website, for anyone who is interested.

Check it out at

All comments welcome!

I thnk OP meant to post this. His keyboard may be broken ?

// calculates the checksum of any given ASCII string using XOR
// sketch by Steve Clements 2019

char dataString[] = "arduino"; //the string source for the checksum
byte xorTemp;

void setup() {


void loop() {
  // print first character ASCII decimal value
  xorTemp = byte(dataString[0]);
  // process the remaining string characters
  for(int i = 1; i < sizeof(dataString) - 1; i++){
    xorTemp ^= byte(dataString[i]);
  // convert the last XOR result to hexadecimal
  Serial.print("The checksum equals ");Serial.println(xorTemp, HEX);