Do you speak (insert programming language name here) ?

A project log for PEAC Pisano with End-Around Carry algorithm

Add X to Y and Y to X, says the song. And carry on.

Yann Guidon / YGDESYann Guidon / YGDES 09/12/2022 at 00:090 Comments

My latest article is published and it's a killer !

It will be fully open around mid-2023. It packs a thorough analysis of existing checksums to deduce/develop the structure and the theory of PEAC checksums. A must-read for anyone who understands French and wants to develop or implement their own checksum!

So I looked around and found that PEAC was picked up by I'd like to contribute a coding example but so far I have only coded it in C, asm and JS. Who wants to make other versions of the checksum in Python, Perl, Pascal, ...Psomethingelse ?

DavidCary, if you read this, here's a first snippet to add to the PEAC page:

// PEAC16x2 algorithm, not unrolled.
// Good practice : Pad the end of the buffer
// with 2 words (can be 0) to increase mixing.

#include <stdint.h>

uint32_t  PEAC16x2(int len, uint16_t *src) {
  uint16_t X=0xABCD;
  uint32_t Y=0x4567,
    C=len;  // add the size of the buffer to the checksum

  while (len > 0) {
    C += X;
    C += Y;
    Y  = X + *src;
    X  = C & 0xFFFF;
    C >>= 16;
  // return 32 bits
  return X | (Y << 16);

The JavaScript version is almost identical, if we modify the declaration, the data types and the array indexing.

// PEAC16x2 algorithm, not unrolled, in JS.

function PEAC16x2(len, src) {
  var X=0xABCD,

  while (len > 0) {
    C += X + Y;
    Y  = X + src[i++];
    X  = C & 0xFFFF;
    C >>= 16;
  return X | (Y << 16);

What's next ?