mjwt

package
v0.7.9 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToPrivateKey

func BytesToPrivateKey(priv []byte) (*rsa.PrivateKey, error)

BytesToPrivateKey bytes to private key

func BytesToPublicKey

func BytesToPublicKey(pub []byte) (*rsa.PublicKey, error)

BytesToPublicKey bytes to public key

func DecryptWithPrivateKey

func DecryptWithPrivateKey(ciphertext []byte, priv *rsa.PrivateKey) ([]byte, error)

DecryptWithPrivateKey decrypts data with private key

func EncryptWithPublicKey

func EncryptWithPublicKey(msg []byte, pub *rsa.PublicKey) ([]byte, error)

EncryptWithPublicKey encrypts data with public key

func GenRSA256Token

func GenRSA256Token(claims CustomClaims, privateKey *rsa.PrivateKey, publicKey *rsa.PublicKey) (string, error)

GenRSA256Token 生成 密钥对加密的 token

func GenRSA256TokenByFile

func GenRSA256TokenByFile(claims CustomClaims, priKeyFile, pubKeyFile string) (string, error)

GenRSA256TokenByFile

func GenRSA256TokenByFilePwd

func GenRSA256TokenByFilePwd(claims CustomClaims, priKeyFile, pubKeyFile, keyPwd string) (string, error)

GenRSA256TokenByFilePwd

func GenerateKeyPair

func GenerateKeyPair(bits int) (*rsa.PrivateKey, *rsa.PublicKey, error)

GenerateKeyPair generates a new key pair

func GetPriKey

func GetPriKey(priKeyFile string) (*rsa.PrivateKey, error)

获取私钥

func GetPriKeyPwd

func GetPriKeyPwd(priKeyFile, pwd string) (*rsa.PrivateKey, error)

获取 加密码的私钥

func GetPubKey

func GetPubKey(pubKeyFile string) (*rsa.PublicKey, error)

获取公钥

func PrivateKeyToBytes

func PrivateKeyToBytes(priv *rsa.PrivateKey) []byte

PrivateKeyToBytes private key to bytes

func PublicKeyToBytes

func PublicKeyToBytes(pub *rsa.PublicKey) ([]byte, error)

PublicKeyToBytes public key to bytes

Types

type CustomClaims

type CustomClaims struct {
	Data      []byte `json:"data"`
	ExtraData []byte `json:"extra_data"`
	jwt.StandardClaims
}

func ParseRAS256TokenByFile

func ParseRAS256TokenByFile(token string, priKeyFile, pubKeyFile string) (*CustomClaims, error)

ParseRAS256TokenByFile

func ParseRAS256TokenByFilePwd

func ParseRAS256TokenByFilePwd(token string, priKeyFile, pubKeyFile, keyPwd string) (*CustomClaims, error)

ParseRAS256TokenByFilePwd

func ParseRAS256TokenByKey

func ParseRAS256TokenByKey(token string, privateKey *rsa.PrivateKey, publicKey *rsa.PublicKey) (*CustomClaims, error)

ParseRAS256TokenByKey 解析token

Jump to

Keyboard shortcuts

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