XORCrypt is a simple command-line utility which allows you to encrypt files using a password.
As it's name implies, it uses XOR encryption.
This utility is not designed to protect sensitive data.
Do NOT use this utility to protect sensitive information as XOR encryption not secure enough for such application.
If you're looking for a secure alternative, try the free and open-source rclone
or Cryptomator.
clap
- For command-line argument parsing
rpassword
- Allows reading passwords from the command-line
spinoff
- Allows displaying cool spinners.
Simple encrypt, password will be requested from stdin.
xorcrypt data.txt -o data.txt.encrypted
Or you can pass a password as an argument.
xorcrypt -p superpassword123 data.txt -o data.txt.encrypted
Decryption: (-p
can also be used here)
xorcrypt -r data.txt.encrypted -o data.txt
For help use xorcrypt --help
.
You can simply clone this repo and use cargo run
to build the app. No additional configuration is needed.
- ✅ Windows
- ✅ macOS (x86 & ARM)
- ✅ Linux (x86 & ARM)
XORCrypt reads N
bytes from the source file in a loop. N
is the length of the password. Next, each byte from the N
-sized buffer is XORed with a byte (ASCII code) from the password.
Let's define a password: code
.
Let's say the data we're trying to encrypt (in hexadecimal) is FE ED BE EF
.
FE ED BE EF
^^ ^^ ^^ ^^
| | | |- XOR with 'e' (0x65)
| | |- XOR with 'd' (0x6E)
| |- XOR with 'o' (0x6F)
|- XOR with 'c' (0x63)
End result is:
FE ^ 63 = 9D
ED ^ 6F = 82
BE ^ 6E = D0
EF ^ 65 = 8A
The encrypted data is 9D 82 D0 8A
.
Files encrypted using XORCrypt will start with a "magic byte". This is used to allow XORCrypt to detect whether this file was encrypted or not. This magic byte is defined here.