aboutsummaryrefslogtreecommitdiffstats
path: root/src/c_utils.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/c_utils.go')
-rw-r--r--src/c_utils.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/c_utils.go b/src/c_utils.go
index df49a4f..01c8665 100644
--- a/src/c_utils.go
+++ b/src/c_utils.go
@@ -54,6 +54,8 @@ package main
import (
"fmt"
"os"
+ "os/exec"
+ "strings"
)
// this function will go get the data folder and try to create it if it does
@@ -117,3 +119,19 @@ func c_error_mode(msg string, err error, ui *HardUI) {
ui.err[ERROR_MSG] = msg
ui.err[ERROR_ERR] = err_str
}
+
+// c_encrypt_str encrypts a string with the given gpgkey
+func c_encrypt_str(str string, gpg string) (string, error) {
+ cmd := exec.Command("gpg", "-r", gpg, "-a", "-e")
+ cmd.Stdin = strings.NewReader(str)
+ out, err := cmd.Output()
+ return string(out), err
+}
+
+// c_decrypt_str will try to decrypt the given str
+func c_decrypt_str(str string) (string, error) {
+ cmd := exec.Command("gpg", "-q", "-d")
+ cmd.Stdin = strings.NewReader(str)
+ out, err := cmd.Output()
+ return string(out), err
+}