Last active
November 13, 2018 19:55
-
-
Save yottatsa/4e30d2059d72a5bd61c8b3792eebb9d8 to your computer and use it in GitHub Desktop.
re-crypt asymmetrically encrypted files using symmetric encryption (e.g for back up)
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 -eu | |
# this is a self-verifying shell script | |
exec sh -eu -c "$(gpg -o - --verify "${0}")" "${0}" "$@" | |
-----BEGIN PGP SIGNED MESSAGE----- | |
Hash: SHA256 | |
#!/bin/sh -eu | |
set -o pipefail | |
exec 2>> "${0}.log" | |
set -x | |
if test "$#" -eq 0 | |
then | |
DIR="$(mktemp -d)" | |
cp "${0}" "${DIR}/" | |
echo "${DIR}" | |
echo "${PASSPHRASE}" | |
exec find ./ -name '*.gpg' ! -path '*/vk/*' -print0 | exec xargs -0 "${0}" "${DIR}" | |
else | |
DIR="${1}" | |
shift | |
for f | |
do | |
out="${DIR}/$(dirname "${f}")" | |
mkdir -p "${out}" | |
file="$(basename "${f}")" | |
temp="$(mktemp "${out}/${file}.XXXXXX")" | |
gpg --decrypt -o - "${f}" | gpg -c --passphrase "${PASSPHRASE}" --batch --armor > "${temp}" | |
mv "${temp}" "${out}/${file}" | |
done | |
fi | |
-----BEGIN PGP SIGNATURE----- | |
iQIzBAEBCAAdFiEEUivlR1m9a/9HyLuX2rsuCYkqnPIFAlvrJdYACgkQ2rsuCYkq | |
nPKXlg/7BIdIgSNBdMVx5301YIDt5gX9NgT32h4ApeSeuFw4ab4B+JrNQBFhQpbk | |
3R17l62zHJyURBUN8LPzzWxStewPfX5xL07KoveZ56A8veFDxIfQHypFtvuwshRX | |
ctRhUxOW6mTpHcbrBhzPMdmJIo7FPfV40S/zZ/XPCFobz+0o7Dq0qdVkvm24xAmS | |
4yzmbJULaZe276ENI1ZErh5AEWDLrT0T+GlSozcAuwOLuYKS8vDvOda+xng/+HIy | |
wU+EfVQ0Os5w4k8G7ocrto43Y8ZLfs2+GJSSjrQemlxTNjXCpKRk5WW3+ZJtatsV | |
/vrnKbIqaIymRttv0O2xW5Q+SKhq10QLnoOxuHthDDmYD5XWJWj2/26mVoCJ6+xd | |
2yoD103btvwpdHoC809W6EfHL/0eXgkTqdTMjYWx0gwNdLAY0WlEV8cAq1o4rHnS | |
Tb3Km9A0JmFGGERxYU7dWY7dgtNoxipq5bnCCsBY6ekVOrbHYzxBQfTY9dtnkNUr | |
DMxmGL8gDY04CY7R9AMH103bctDdK5OtpedZUs255K12jiSa5YDPljwpC0+Wmd7d | |
sXuVCRsOdYMW+BHRu+dORhaOTDm+ScmvxSTsZV3/wtCtyejDJknqLKC3byuKqUqw | |
GuACQB6ps+G9sO7Auc0ELDJXtoNlyXK2slBdRNyd8CfRVbhNrWs= | |
=5ipb | |
-----END PGP SIGNATURE----- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment