We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c9bbe0a commit bfb7993Copy full SHA for bfb7993
cmd/commons/utils/base64.go
@@ -0,0 +1,22 @@
1
+package utils
2
+
3
+import (
4
+ "encoding/base64"
5
+ log "github.com/sirupsen/logrus"
6
+)
7
8
+// EncodeString Base64Encode encodes the given string to base64
9
+func EncodeString(str string) string {
10
+ return base64.StdEncoding.EncodeToString([]byte(str))
11
+}
12
13
+// DecodeString decode the base64 string return string
14
+func DecodeString(str string) string {
15
+ decoded, err := base64.StdEncoding.DecodeString(str)
16
+ if err != nil {
17
+ log.Debug("Error decoding base64 string: ", err)
18
+ return ""
19
+ } else {
20
+ return string(decoded)
21
+ }
22
0 commit comments