about summary refs log tree commit diff
path: root/functions/gpg_functions.sh
blob: 267c40105000fedf95edd5a36564ac8359c28b79 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env zsh

function gpg-encrypt-dir() {
    dirname=$1
    echo "Encrypting..."
    tar -cz "$dirname" | gpg --symmetric --output "$dirname.tar.gz.gpg"
    echo "Done."
}


function gpg-decrypt-dir() {
    dirname=$1
    outdir=${dirname%.tar.gz.gpg}

    if [ -d "$outdir" ]; then
        echo "Output directory, $outdir, already exists and will be overwritten by this command. Aborting..."
        exit 1
    else
        echo "Decrypting..."
        gpg --decrypt $dirname | tar -xv
        echo "Done."
    fi

}


# WIP
function gpg-encrypt-file() {
    filename=$1
    echo "Encrypting..."
    gpg --symmetric $filename
    echo "Done."
}


# WIP
function gpg-decrypt-file() {
    filename=$1
    echo "Decrypting..."
    gpg --decrypt $filename >"${filename%.gpg}"
    echo "Done."
}