Skip to content

Commit 12bed74

Browse files
Add files via upload
1 parent 0610a05 commit 12bed74

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

EncryptDecryptXOR.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include<stdio.h>
2+
#include<string.h>
3+
4+
char XORkey[12] = {'F','P','k','k','Y','P','l','p','V','P','L','z'};
5+
void encryptDecrypt();
6+
7+
int main() {
8+
char sampleString[] = " This contains highly sensitive message\n" \
9+
" coordinates : 23.445, 34.443\n" \
10+
" All further messages MUST be send via\n" \
11+
" XOR encryption only - Long Live Revolution!!\n" ;
12+
13+
14+
printf("\nEncrypted String :\n");
15+
encryptDecrypt(sampleString);
16+
17+
printf("\nDecyrpted String :\n");
18+
encryptDecrypt(sampleString);
19+
20+
return 0;
21+
}
22+
23+
void encryptDecrypt(char inputString[]) {
24+
int i = 0;
25+
26+
int len = strlen(inputString);
27+
for (i = 0; i < len; i++) {
28+
inputString[i] = inputString[i] ^ XORkey[i % (sizeof(XORkey)/sizeof(char))];
29+
printf("%c", inputString[i]);
30+
}
31+
32+
}
33+

0 commit comments

Comments
 (0)