Implement fixed XOR
This commit is contained in:
parent
11bb1ef661
commit
bdb02a337b
|
@ -1,10 +1,11 @@
|
|||
CC = gcc
|
||||
CFLAGS = -Wall -Wpedantic -Wextra -std=c99
|
||||
DEBUG = -g
|
||||
CFLAGS = -Wall -Wpedantic -Wextra -std=c99 -fstack-protector-all \
|
||||
-fdiagnostics-color=auto
|
||||
DEBUG = -0g -ggdb
|
||||
LINK =
|
||||
SRC_DIR = src
|
||||
OUT_DIR = bin
|
||||
TARGETS = base64
|
||||
TARGETS = base64 fixed-xor
|
||||
|
||||
|
||||
all: $(TARGETS)
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*
|
||||
void fixed_xor_stream(uint8_t *key, size_t key_len)
|
||||
{
|
||||
//
|
||||
}
|
||||
*/
|
||||
|
||||
void fixed_xor(const uint8_t *data, const uint8_t *key, const size_t key_len)
|
||||
{
|
||||
uint8_t c;
|
||||
size_t i;
|
||||
for (i = 0; i < key_len; ++i) {
|
||||
c = data[i] ^ key[i];
|
||||
putchar(c);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char data[] = "\x1c\x01\x11\x00\x1f\x01\x01\x00\x06\x1a\x02\x4b\x53\x53\x50\x09\x18\x1c";
|
||||
char key[] = "\x68\x69\x74\x20\x74\x68\x65\x20\x62\x75\x6c\x6c\x27\x73\x20\x65\x79\x65";
|
||||
|
||||
fixed_xor(data, key, sizeof(key));
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue