添加基础类

This commit is contained in:
2022-11-02 19:34:45 +08:00
parent e36c37b39b
commit bdc4a13e83
11 changed files with 1074 additions and 0 deletions

28
internal/sign/base64.go Normal file
View File

@@ -0,0 +1,28 @@
/**
* @Author: Echo
* @Author:1711788888@qq.com
* @Date: 2021/5/27 19:15
* @Desc: BASE64
*/
package sign
import (
"encoding/base64"
"strings"
)
func base64urlEncode(data []byte) string {
str := base64.StdEncoding.EncodeToString(data)
str = strings.Replace(str, "+", "*", -1)
str = strings.Replace(str, "/", "-", -1)
str = strings.Replace(str, "=", "_", -1)
return str
}
func base64urlDecode(str string) ([]byte, error) {
str = strings.Replace(str, "_", "=", -1)
str = strings.Replace(str, "-", "/", -1)
str = strings.Replace(str, "*", "+", -1)
return base64.StdEncoding.DecodeString(str)
}