yjp 1 год назад
Родитель
Сommit
564808b3c6
1 измененных файлов с 8 добавлено и 0 удалено
  1. 8 0
      encoding/encoding.go

+ 8 - 0
encoding/encoding.go

@@ -66,6 +66,14 @@ func SHA256(origin string, salt string) string {
 	return fmt.Sprintf("%x", sha256.Sum256([]byte(origin)))
 }
 
+func Base64Encode(content []byte) string {
+	return base64.StdEncoding.EncodeToString(content)
+}
+
+func Base64Decode(content string) ([]byte, error) {
+	return base64.StdEncoding.DecodeString(content)
+}
+
 func pkcs7Padding(ciphertext []byte, blockSize int) []byte {
 	padding := blockSize - len(ciphertext)%blockSize
 	padText := bytes.Repeat([]byte{byte(padding)}, padding)