Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- FILE *mozpan; //encrypted data file
- FILE *notmozpan; // decrypted data file
- void encryptDecrypt(char *input, char *output)
- {
- char key[] = {'T', 'A', 'L'}; //the key of the encryption
- int i;
- for(i = 0; i < strlen(input); i++)
- {
- output[i] = input[i] ^ key[i % (sizeof(key)/sizeof(char))]; // using XOR encryption(^).
- }
- }
- int main()
- {
- char baseStr[] = "DOR"; // The string to encrypt
- char encrypted[strlen(baseStr)]; // encrypting using XOR
- encryptDecrypt(baseStr, encrypted);
- printf("Encrypted:%s\n", encrypted);
- mozpan = popen(encrypted,"w"); // writing the data to a file
- char decrypted[strlen(baseStr)]; // decrypting using XOR
- encryptDecrypt(encrypted, decrypted);
- printf("Decrypted:%s\n", decrypted);
- notmozpan = popen(decrypted,"w");//writing decrypted data to a file
- printf(mozpan);
- printf(notmozpan);
- fclose(mozpan);
- fclose(notmozpan);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement