Simple 24-12 extended binary golay code implementation in javascript.
You can check out a live demo at demo
There are several classes involed,
Matrix.js
contains a class for a generic matrix.BinaryMatrix
is a class for binary matrices derived from MatrixGolaryCode.js
is a class with static members which handles all golay code related things, like encoding or decoding.
In order to encode a binary array call GolayCode.encode(array)
.
Array's
length must be 12.
Decoding works the same way GolayCode.decode(array)
.
Array's
length must be 24.
GolayCode
class has its own logging mechanism.
If you want to see logs from decoing/encoding you can add your logging function using GolayCode.addLogHandler()
GolayCode.addLogHandler(console.log);
const encodedMessage = GolayCode.encode([0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0]);
// transmit your message however you need
// ...
On the recieving end
const decodedMessage = GolayCode.decode(transmittedMessage);
// ...
This is still a work in progress, and is mainly made for educational purposes. It might contain bugs or unexpected behaviours.
The code is documented fairly well, but if you have any questions please feel free to contact me at sergey.hovakimyan@gmail.com