#include #include #include #include void encrypt_block(void* data, uint8_t key){ uint8_t *typed_data = (uint8_t*)data; for(int i = 0; i < 4; i++){ typed_data[i] += key; } } // It'll encrypted void encrypt_data(void* data, uint8_t key, size_t datasize){ size_t offset = 0; while(offset < datasize){ encrypt_block(data + offset, key); offset += 4; } } #define BUFSIZE (1024*1024) int main(int argc, char ** argv){ uint8_t key = atoi(argv[1]); uint8_t buffer[BUFSIZE]; ssize_t readlen; for(;;){ readlen = read(0, buffer, BUFSIZE); if(readlen < 1) break; encrypt_data(buffer, key, readlen); write(1, buffer, readlen); write(2, "beep\n", 5); } return 0; }