Hot, low speed CHACHA20 encryption in Bash
This is an implementation of ChaCha20 (also) encryption without any external programs. No dependencies, other than a recent version of bash.
WARNING: THIS IS EXTREMELY SLOW AND INEFFICIENT. DO NOT USE IT FOR ANY SERIOUS PURPOSE, AND DO NOT USE IT ON LARGE AMOUNTS OF DATA (EVEN A FEW TENS OF KB ARE ALREADY A LOT FOR THIS BEAST). YOU HAVE BEEN WARNED.
See the following comparison with openssl to encrypt a file:
$ ls -al /bin/w
-rwxr-xr-x 1 root root 22576 Feb 13 20:05 /bin/w
$ time openssl chacha20 -K 9900000000000000000000000000000000000000000000000000000000000001 -iv 00000000000000002607000a00040001 < /bin/w > /dev/null
real 0m0.005s
user 0m0.005s
sys 0m0.000s
$ time ./chacha.sh -K 9900000000000000000000000000000000000000000000000000000000000001 -I 2607000a00040001 < /bin/w > /dev/null
real 0m7.388s
user 0m7.099s
sys 0m0.140s
Just run the chacha.sh
script with the necessary arguments (see chacha.sh -h
for help).
There are two test scripts in the tests/
directory, whose job is to compare results from chacha.sh
and openssl chacha20
(see comments in the scripts). All tests should pass.