Skip to content

Instantly share code, notes, and snippets.

@pandasauce
Created July 19, 2017 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pandasauce/6d888320077e6b7cd69d64c0efafcc64 to your computer and use it in GitHub Desktop.
Save pandasauce/6d888320077e6b7cd69d64c0efafcc64 to your computer and use it in GitHub Desktop.
Xorist 101
#include <stdio.h>
#include <memory.h>
#include <stdlib.h>
#define LENGTH 20
int main()
{
char const plainone[LENGTH] = "BASIC XOR CRYPTO";
char const plaintwo[LENGTH] = "WINKWINKWINKWINK";
char xor[LENGTH];
int i;
for(i = 0; i < LENGTH; ++i) {
xor[i] = (char)(plainone[i] ^ plaintwo[i]);
}
printf("Input: %s\nKey: %s\n\nXOR: ", plainone, plaintwo);
for(i = 0; i < LENGTH; ++i) {
printf("%02X ", xor[i]);
}
printf("\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment