Skip to content
/ xor Public

Symmetric xor encryption / decryption in C.

License

Notifications You must be signed in to change notification settings

koppi/xor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XOR cipher

A C implementation of the simple XOR cipher for encrypting and decrypting arbitrary files.

Makefile CI CodeQL Join the chat at https://gitter.im/koppi/xor

Clone, compile and install

git clone https://github.com/koppi/xor && sudo make -C xor release install

(Note: using simply make instead of make release will produce debug versions of the tools with the address sanitizer and undefined behavior sanitizer enabled.)

or

curl -L 'https://github.com/koppi/xor/raw/master/xor.c' | gcc -O2 -x c -o /usr/local/bin/xor -

Usage

xor -e abc.key -i abc.txt -o abc.enc # to encrypt
xor -d abc.key -i abc.enc -o abc.txt # to decrypt

where:

  • abc.txt is the plaintext file,
  • abc.key is the single-use pre-shared key,
  • abc.enc is the encrypted file.

Hints

  • to speed up the key stream generation of the Linux pseudo-random number generator, install haveged:
sudo apt -y install haveged

With a key that is truly random, the result is a one-time pad, which is unbreakable in theory.

Author