Documentation
¶
Index ¶
- func BytesToPrivateKey(priv []byte) (*rsa.PrivateKey, error)
- func BytesToPublicKey(pub []byte) (*rsa.PublicKey, error)
- func DecryptWithPrivateKey(ciphertext []byte, priv *rsa.PrivateKey) ([]byte, error)
- func EncryptWithPublicKey(msg []byte, pub *rsa.PublicKey) ([]byte, error)
- func GenRSA256Token(claims CustomClaims, privateKey *rsa.PrivateKey, publicKey *rsa.PublicKey) (string, error)
- func GenRSA256TokenByFile(claims CustomClaims, priKeyFile, pubKeyFile string) (string, error)
- func GenRSA256TokenByFilePwd(claims CustomClaims, priKeyFile, pubKeyFile, keyPwd string) (string, error)
- func GenerateKeyPair(bits int) (*rsa.PrivateKey, *rsa.PublicKey, error)
- func GetPriKey(priKeyFile string) (*rsa.PrivateKey, error)
- func GetPriKeyPwd(priKeyFile, pwd string) (*rsa.PrivateKey, error)
- func GetPubKey(pubKeyFile string) (*rsa.PublicKey, error)
- func PrivateKeyToBytes(priv *rsa.PrivateKey) []byte
- func PublicKeyToBytes(pub *rsa.PublicKey) ([]byte, error)
- type CustomClaims
- func ParseRAS256TokenByFile(token string, priKeyFile, pubKeyFile string) (*CustomClaims, error)
- func ParseRAS256TokenByFilePwd(token string, priKeyFile, pubKeyFile, keyPwd string) (*CustomClaims, error)
- func ParseRAS256TokenByKey(token string, privateKey *rsa.PrivateKey, publicKey *rsa.PublicKey) (*CustomClaims, error)
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 ¶
BytesToPublicKey bytes to public key
func DecryptWithPrivateKey ¶
func DecryptWithPrivateKey(ciphertext []byte, priv *rsa.PrivateKey) ([]byte, error)
DecryptWithPrivateKey decrypts data with private key
func EncryptWithPublicKey ¶
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 ¶
GenerateKeyPair generates a new key pair
func PrivateKeyToBytes ¶
func PrivateKeyToBytes(priv *rsa.PrivateKey) []byte
PrivateKeyToBytes private 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
Click to show internal directories.
Click to hide internal directories.