Отличная простейшая кодировка строки, или файла методом XOR.
#include <stdio.h> #include <stdlib.h> char pass[] = "secret"; char buff[] = "Hello, World!"; void strxor(char* x, int xl, char* n, int nl) { for ( int i=0 ; i<xl ; i++ ) { char pwdor = n[i%nl]; x[i] = (x[i] ^ pwdor) & 0xFF; } } int main() { int blen = sizeof(buff); char* buff1 = (char*) malloc(blen); memcpy(buff1, buff, blen); strxor(buff1, blen, pass, strlen(pass)); char* buff2 = (char*) malloc(blen); memcpy(buff2, buff1, blen); strxor(buff2, blen, pass, strlen(pass)); for ( int i=0 ; i<blen ; i++ ) { // Textual Out printf("%C ", buff[i]); } printf("\n"); for ( int i=0 ; i<blen ; i++ ) { // HEX out printf("%02X ", buff[i]); } printf("\n"); for ( int i=0 ; i<blen ; i++ ) { // Encrypted out printf("%02X ", buff1[i]); } printf("\n"); for ( int i=0 ; i<blen ; i++ ) { // Encrypted textual printf("%C ", buff1[i]); } printf("\n"); for ( int i=0 ; i<blen ; i++ ) { // Decrypted textual printf("%C ", buff2[i]); } printf("\n"); free(buff1); free(buff2); return 0; }