Skip to content

Commit e60b51b

Browse files
committed
encrypt/decrypt archives
1 parent a41741b commit e60b51b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,30 @@ function mkdir.mp3() {
117117
}
118118
```
119119

120+
## Encrypt/decrypt tar archives
121+
122+
```
123+
function tar.encrypt() {
124+
# $1...: files or folders to encrypt
125+
if [ "$#" == 0 ]; then
126+
echo Usage: encrypt \<file\> [\<file\> ...]
127+
return 1
128+
else
129+
tar czvpf - "$@" | gpg --symmetric --cipher-algo aes256 -o archive.tar.gz.gpg
130+
fi
131+
}
132+
133+
function tar.decrypt() {
134+
# $1: archive to decrypt
135+
if [ "$#" != 1 ]; then
136+
echo Usage: decrypt \<archive\>
137+
return 1
138+
else
139+
gpg -d $1 | tar xzvf -
140+
fi
141+
}
142+
```
143+
120144
## Appendix: Bash programming reference
121145

122146
<https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html>

0 commit comments

Comments
 (0)