mirror of
https://github.com/KyleBanks/XOREncryption.git
synced 2023-08-10 21:13:15 +03:00
Added C implementation
This commit is contained in:
parent
5bee6f4202
commit
50cdacb50d
23
C/main.c
Normal file
23
C/main.c
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
void encryptDecrypt(char *input, char *output) {
|
||||||
|
char key[] = {'K', 'C', 'Q'}; //Can be any chars, and any size array
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for(i = 0; i < strlen(input); i++) {
|
||||||
|
output[i] = input[i] ^ key[i % (sizeof(key)/sizeof(char))];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main (int argc, char *argv[]) {
|
||||||
|
char baseStr[] = "kylewbanks.com";
|
||||||
|
|
||||||
|
char encrypted[strlen(baseStr)];
|
||||||
|
encryptDecrypt(baseStr, encrypted);
|
||||||
|
printf("Encrypted:%s\n", encrypted);
|
||||||
|
|
||||||
|
char decrypted[strlen(baseStr)];
|
||||||
|
encryptDecrypt(encrypted, decrypted);
|
||||||
|
printf("Decrypted:%s\n", decrypted);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user