2017-07-15 19:49:28 +00:00
|
|
|
#include "stdio.h"
|
|
|
|
#include "stdint.h"
|
|
|
|
#include "string.h"
|
2017-11-15 18:03:29 +00:00
|
|
|
#include "../libhagelbarger/hagelbarger.h"
|
2017-07-15 19:49:28 +00:00
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
uint8_t message[9] = "JollyRog", code[20];
|
|
|
|
|
|
|
|
printf("Message: %s\n", message);
|
|
|
|
|
2017-07-24 17:18:01 +00:00
|
|
|
/* clean tail at code bit 70 and above */
|
2017-07-15 19:49:28 +00:00
|
|
|
memset(code, 0, sizeof(code));
|
|
|
|
|
|
|
|
/* encode message */
|
2017-07-24 17:18:01 +00:00
|
|
|
hagelbarger_encode(message, code, 70);
|
|
|
|
|
|
|
|
/* decode */
|
|
|
|
hagelbarger_decode(code, message, 64);
|
|
|
|
printf("Decoded without corruption: %s (must be the same as above)\n", message);
|
2017-07-15 19:49:28 +00:00
|
|
|
|
|
|
|
/* corrupt data */
|
|
|
|
code[0] ^= 0xfc;
|
|
|
|
code[3] ^= 0xfc;
|
|
|
|
code[7] ^= 0xfc;
|
|
|
|
|
|
|
|
/* decode */
|
|
|
|
hagelbarger_decode(code, message, 64);
|
2017-07-24 17:18:01 +00:00
|
|
|
printf("Decoded with corruption: %s (must be the same as above)\n", message);
|
2017-07-15 19:49:28 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|