aboutsummaryrefslogtreecommitdiffstats
path: root/src/c_utils.go
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-01-31 20:20:20 +0100
committerJoe <rbo@gmx.us>2024-01-31 20:20:20 +0100
commit98bc232593015bb368635da0a3716c61850695a2 (patch)
tree43910c482bdcb24702a75e9daece7432443fe015 /src/c_utils.go
parentgood start (diff)
downloadhardflip-98bc232593015bb368635da0a3716c61850695a2.tar.gz
hardflip-98bc232593015bb368635da0a3716c61850695a2.tar.bz2
hardflip-98bc232593015bb368635da0a3716c61850695a2.tar.xz
hardflip-98bc232593015bb368635da0a3716c61850695a2.tar.zst
hardflip-98bc232593015bb368635da0a3716c61850695a2.zip
qwe
Diffstat (limited to '')
-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
+}