Skip to content

Commit

Permalink
feat(str): add b64 string to string func.
Browse files Browse the repository at this point in the history
  • Loading branch information
Esonhugh committed Dec 7, 2021
1 parent 7e43bc0 commit 2d2dcb1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions utils/str.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,24 @@ import (
"crypto/hmac"
"crypto/md5"
"crypto/sha1"
"encoding/base64"
"encoding/hex"
"fmt"
"io"
)

func B64encode(content string) string {
return base64.StdEncoding.EncodeToString([]byte(content))
}

func B64decode(content string) (string, error) {
data, err := base64.StdEncoding.DecodeString(content)
if err != nil {
return "", err
}
return string(data), nil
}

func Sha1(content string) string {
h := sha1.New()
h.Write([]byte(content))
Expand Down

0 comments on commit 2d2dcb1

Please sign in to comment.