1 Star 0 Fork 1

unsafe-rust / jwt-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
signing_method.go 931 Bytes
一键复制 编辑 原始数据 按行查看 历史
package jwt
var signingMethods = map[string]func() SigningMethod{}
// Implement SigningMethod to add new methods for signing or verifying tokens.
type SigningMethod interface {
Verify(signingString, signature string, key interface{}) error // Returns nil if signature is valid
Sign(signingString string, key interface{}) (string, error) // Returns encoded signature or error
Alg() string // returns the alg identifier for this method (example: 'HS256')
}
// Register the "alg" name and a factory function for signing method.
// This is typically done during init() in the method's implementation
func RegisterSigningMethod(alg string, f func() SigningMethod) {
signingMethods[alg] = f
}
// Get a signing method from an "alg" string
func GetSigningMethod(alg string) (method SigningMethod) {
if methodF, ok := signingMethods[alg]; ok {
method = methodF()
}
return
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/unsafe-rust/jwt-go.git
git@gitee.com:unsafe-rust/jwt-go.git
unsafe-rust
jwt-go
jwt-go
v2.7.0

搜索帮助

344bd9b3 5694891 D2dac590 5694891