mirror of
https://github.com/rwinkhart/sshyp-labs.git
synced 2026-08-28 04:46:48 -04:00
20 lines
649 B
Go
20 lines
649 B
Go
package main
|
|
|
|
import (
|
|
"os/exec"
|
|
"strings"
|
|
|
|
"github.com/rwinkhart/go-boilerplate/back"
|
|
"github.com/rwinkhart/libmutton/global"
|
|
)
|
|
|
|
// decryptGPG decrypts a GPG-encrypted file and returns the contents as a slice of (trimmed) strings.
|
|
func decryptGPG(targetLocation string) []string {
|
|
cmd := exec.Command("gpg", "--pinentry-mode", "loopback", "-q", "-d", targetLocation)
|
|
output, err := cmd.Output()
|
|
if err != nil {
|
|
back.PrintError("Failed to decrypt \""+targetLocation+"\" - Ensure it is a valid GPG-encrypted file and that you entered your passphrase correctly", global.ErrorDecryption, true)
|
|
}
|
|
return strings.Split(string(output), "\n")
|
|
}
|