valid

package
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package valid

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenRsaKey

func GenRsaKey(bits int, pubWt io.Writer, prvWt io.Writer) error

func RsaDecrypt

func RsaDecrypt(ciphertext, keyBytes []byte) ([]byte, error)

私钥解密

func RsaEncrypt

func RsaEncrypt(data, keyBytes []byte) ([]byte, error)

公钥加密

func RsaSignWithSha256

func RsaSignWithSha256(data []byte, keyBytes []byte) ([]byte, error)

私钥签名

func RsaVerySignWithSha256

func RsaVerySignWithSha256(data, signData, keyBytes []byte) bool

公钥验证

Types

type CustomClaims

type CustomClaims struct {
	Stash map[string]string
	jwt.StandardClaims
}

func (*CustomClaims) SetStash

func (s *CustomClaims) SetStash(stash map[string]string)

type JwtWithRsa

type JwtWithRsa struct {
	PubKey []byte
	PrvKey []byte
}

func NewJwtWithRsa

func NewJwtWithRsa(pubKey, prvKey []byte) *JwtWithRsa

使用Rsa签名token

func (*JwtWithRsa) Generate

func (sel *JwtWithRsa) Generate(stash map[string]string, exp int64) (string, error)

stash 可以存储用户自己的数据 exp 过期时间 分钟

func (*JwtWithRsa) Verify

func (sel *JwtWithRsa) Verify(dt string) (stash map[string]string, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL