Skip to content

Instantly share code, notes, and snippets.

@idodeclare
Created December 31, 2019 18:22
Show Gist options
  • Save idodeclare/5b07f5143d9115e3ce4128938895a55a to your computer and use it in GitHub Desktop.
Save idodeclare/5b07f5143d9115e3ce4128938895a55a to your computer and use it in GitHub Desktop.
#!/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