✨ 添加基础类
This commit is contained in:
28
internal/sign/base64.go
Normal file
28
internal/sign/base64.go
Normal 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)
|
||||
}
|
Reference in New Issue
Block a user