#include <stdio.h>
#include <stdint.h>

uint8_t SECRET_KEY = 0x5f;



uint8_t XOR(uint8_t a, uint8_t b) {

    return a ^ b;
}

uint8_t encrypt(uint8_t input) {
    uint8_t tmp = input;

    for(int i=0; i < 7; i++) {
        tmp = XOR(tmp, SECRET_KEY);
    }

    return tmp;
}



void test_masked() {
    uint8_t mask = 0xFF;

    uint8_t pt = 0xBB;

    uint8_t masked_pt = XOR(mask, pt);
    uint8_t masked_ct = encrypt(masked_pt);

    uint8_t ct = XOR(masked_ct, mask);
    printf("Encrypted to: 0x%02x\n", ct);

}

void test_normal() {

    uint8_t pt = 0xBB;

    uint8_t ct = encrypt(pt);

    printf("Encrypted to: 0x%02x\n", ct);

}

int main() {

    test_normal();
    test_masked();

    return 0;
}