auth

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//rsa 加密公钥
	PublicKey = []byte(`
-----BEGIN PUBLIC KEY-----
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJnNwrj4hi/y3CCJu868ghCG5dUj8wZK
++RNlTLcXoMmdZWEQ/u02RgD5LyLAXGjLOjbMtC+/J9qofpSGTKSx/MCAwEAAQ==
-----END PUBLIC KEY-----
`)
	//rsa 解密私钥
	PrivateKey = []byte(`
-----BEGIN RSA PRIVATE KEY-----
MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAmc3CuPiGL/LcIIm7
zryCEIbl1SPzBkr75E2VMtxegyZ1lYRD+7TZGAPkvIsBcaMs6Nsy0L78n2qh+lIZ
MpLH8wIDAQABAkEAk82Mhz0tlv6IVCyIcw/s3f0E+WLmtPFyR9/WtV3Y5aaejUkU
60JpX4m5xNR2VaqOLTZAYjW8Wy0aXr3zYIhhQQIhAMfqR9oFdYw1J9SsNc+Crhug
AvKTi0+BF6VoL6psWhvbAiEAxPPNTmrkmrXwdm/pQQu3UOQmc2vCZ5tiKpW10CgJ
i8kCIFGkL6utxw93Ncj4exE/gPLvKcT+1Emnoox+O9kRXss5AiAMtYLJDaLEzPrA
WcZeeSgSIzbL+ecokmFKSDDcRske6QIgSMkHedwND1olF8vlKsJUGK3BcdtM8w4X
q7BpSBwsloE=
-----END RSA PRIVATE KEY-----
`)
)

在线生成rsa公钥私钥 http://tool.chacuo.net/cryptrsakeyvalid

Functions

func Base64Decode

func Base64Decode(encoded string) ([]byte, error)

func CheckPwd

func CheckPwd(password, hash string) bool

验证密码

func CheckPwdHash

func CheckPwdHash(_pwd, _hash_pwd string) bool

验证密码

func CreatePwdHash

func CreatePwdHash(_pwd string) (string, error)

生成加密密码

func GetAesDe

func GetAesDe(ciphertext, _key string) (plaintext []byte, err error)

func GetDeRsa

func GetDeRsa(base64Text string) (decryptedMessage string, err error)

func GetUserToken

func GetUserToken(_token string) (_token_map g.Map)

获取用户序token

func HashPwd

func HashPwd(password string) (string, error)

加密密码

func ParsePrivateKey

func ParsePrivateKey(pemKey []byte) (*rsa.PrivateKey, error)

func RSADecrypt

func RSADecrypt(base64Text string, privateKey *rsa.PrivateKey) (string, error)

func SetUserToken

func SetUserToken(_data g.Map) (_token string)

设置用户token

Types

type JWToken

type JWToken struct {
	SignString string
}

JWToken jwt token

func NewJWToken

func NewJWToken(signString string) *JWToken

NewJWToken 创建JWToken对象

func (*JWToken) GenJWToken

func (t *JWToken) GenJWToken(rawContent g.Map) (string, error)

GenJWToken 生成一个jwt token

func (*JWToken) ParseJWToken

func (t *JWToken) ParseJWToken(tokenString string) (g.Map, error)

ParseJWToken 解析 JWToken

Jump to

Keyboard shortcuts

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