12
encrypted += original[temp] ^ (int(key) + temp) % 255; unencrypted += encrypted[temp] ^ (int(key) + temp) % 255;
(int(key) + temp) % 255
1234567891011121314151617181920212223242526272829303132333435363738394041424344
//Includes #include <stdio.h> #include <conio.h> #include <windows.h> //Functions void main() { int temp; char original[1000]; char encrypted[1000]; char unencrypted[1000]; char passwd[1000]; printf("\n Encrypt: "); gets(original); printf(" Key: "); gets(passwd); printf("\n\n Unencrypted: %s", original); for (int i = 0; i < strlen(passwd); i++) { for (temp = 0; temp < strlen(original); temp++) { encrypted[temp] = original[temp] ^ (int(passwd[i]) + temp) % 255; } } encrypted[temp] = '\0'; printf("\n Encrypted: %s", encrypted); for (int i = 0; i < strlen(passwd); i++) { for (temp = 0; temp < strlen(original); temp++) { unencrypted[temp] = encrypted[temp] ^ (int(passwd[i]) + temp) % 255; } } unencrypted[temp] = '\0'; printf("\n Unencrypted: %s", unencrypted); _getch(); }