Created
December 31, 2019 18:22
-
-
Save idodeclare/5b07f5143d9115e3ce4128938895a55a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
keylength=8 | |
algo=$1 | |
[[ "$algo" = "aes" ]] && keylength=16 | |
[[ "$algo" = "3des" ]] && keylength=24 | |
encfile=$(mktemp -t _encXXXXXX) && \ | |
keyfile=$(mktemp -t _encXXXXXX) && \ | |
dd if=/dev/urandom of="$keyfile" bs="$keylength" count=1 >/dev/null 2>&1 && \ | |
encrypt -a "$algo" -k "$keyfile" -i /etc/resolv.conf -o "$encfile" && \ | |
decrypt -a "$algo" -k "$keyfile" -i "$encfile" | |
rc=$? | |
rm "$encfile" "$keyfile" | |
exit $rc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment