Documentation
¶
Index ¶
- Constants
- func ConvertHexToSM2PrivateKey(hexPrivateKeyStr string) (*sm2.PrivateKey, error)
- func ConvertHexToSM2PublicKey(hexPublicKeyStr string) (*sm2.PublicKey, error)
- func ConvertSM2PrivateKeyToHex(privateKey *sm2.PrivateKey) string
- func ConvertSM2PublicKeyToHex(publicKey *sm2.PublicKey) string
- func DecryptWithRSAPrivateKeyString(privateKeyStr, cipher string) (string, error)
- func DecryptWithRSAPublicKeyString(publicKeyStr, cipher string) (string, error)
- func DecryptWithSM2PrivateKeyString(privateKeyStr, cipher string) (string, error)
- func EncryptWithRSAPrivateKeyString(privateKeyStr, message string) (string, error)
- func EncryptWithRSAPublicKeyString(publicKeyStr, message string) (string, error)
- func EncryptWithSM2PublicKeyString(publicKeyStr, message string) (string, error)
- type AES
- type RSA
- func (r *RSA) Decrypt(cipher string) (string, error)
- func (r *RSA) DecryptWithPrivateKey(cipher string) (string, error)
- func (r *RSA) DecryptWithPublicKey(cipher string) (string, error)
- func (r *RSA) Encrypt(message string) (string, error)
- func (r *RSA) EncryptWithPrivateKey(message string) (string, error)
- func (r *RSA) EncryptWithPublicKey(message string) (string, error)
- func (r *RSA) GetPrivateKey() (string, error)
- func (r *RSA) GetPublicKey() (string, error)
- func (r *RSA) SetPrivateKey(privateKeyStr string) error
- func (r *RSA) SetPublicKey(publicKeyStr string) error
- type SM2
- func NewEmptySM2() *SM2
- func NewSM2() (*SM2, error)
- func NewSM2WithPrivateKey(privateKey *sm2.PrivateKey) *SM2
- func NewSM2WithPrivateKeyHexString(privateKeyStr string) (*SM2, error)
- func NewSM2WithPublicKey(publicKey *sm2.PublicKey) *SM2
- func NewSM2WithPublicKeyHexString(publicKeyStr string) (*SM2, error)
- func (s *SM2) Decrypt(cipher string) (string, error)
- func (s *SM2) DecryptWithPrivateKey(cipher string, mode int) (string, error)
- func (s *SM2) Encrypt(message string) (string, error)
- func (s *SM2) EncryptWithPublicKey(message string, mode int) (string, error)
- func (s *SM2) GetPrivateKey() *sm2.PrivateKey
- func (s *SM2) GetPrivateKeyHexString() string
- func (s *SM2) GetPublicKey() *sm2.PublicKey
- func (s *SM2) GetPublicKeyHexString() string
- func (s *SM2) SetPrivateKey(privateKey *sm2.PrivateKey)
- func (s *SM2) SetPublicKey(publicKey *sm2.PublicKey)
Constants ¶
const ( DefaultAESKeySize = AESKeySize32 AESKeySize16 = 16 AESKeySize24 = 24 AESKeySize32 = 32 )
const (
DefaultRSAKeySize = 1024
)
const (
SM2PublicKeyPrefix = "04"
)
Variables ¶
This section is empty.
Functions ¶
func ConvertHexToSM2PrivateKey ¶ added in v0.3.21
func ConvertHexToSM2PrivateKey(hexPrivateKeyStr string) (*sm2.PrivateKey, error)
func ConvertHexToSM2PublicKey ¶ added in v0.3.21
func ConvertSM2PrivateKeyToHex ¶ added in v0.3.21
func ConvertSM2PrivateKeyToHex(privateKey *sm2.PrivateKey) string
func ConvertSM2PublicKeyToHex ¶ added in v0.3.21
func DecryptWithRSAPrivateKeyString ¶ added in v0.3.21
DecryptWithRSAPrivateKeyString decrypts the data with private key string
func DecryptWithRSAPublicKeyString ¶ added in v0.3.21
DecryptWithRSAPublicKeyString decrypts the data with public key string
func DecryptWithSM2PrivateKeyString ¶ added in v0.3.21
DecryptWithSM2PrivateKeyString decrypts the data with public key string
func EncryptWithRSAPrivateKeyString ¶ added in v0.3.21
EncryptWithRSAPrivateKeyString encrypts the data with private key string
func EncryptWithRSAPublicKeyString ¶ added in v0.3.21
EncryptWithRSAPublicKeyString encrypts the data with public key string
func EncryptWithSM2PublicKeyString ¶ added in v0.3.21
EncryptWithSM2PublicKeyString encrypts the data with public key string
Types ¶
type AES ¶ added in v0.3.21
type AES struct {
// contains filtered or unexported fields
}
func NewAESWithKey ¶ added in v0.3.21
NewAESWithKey returns a new *AES with given key
func NewAESWithKeySize ¶ added in v0.3.21
NewAESWithKeySize returns a new *AES with given key size
type RSA ¶
type RSA struct {
// contains filtered or unexported fields
}
func NewRSAWithKeySize ¶
NewRSAWithKeySize returns a new *RSA with given key size
func NewRSAWithPrivateKey ¶
func NewRSAWithPrivateKey(privateKey *rsa.PrivateKey) *RSA
NewRSAWithPrivateKey returns a new *RSA with given private key
func NewRSAWithPrivateKeyString ¶
NewRSAWithPrivateKeyString returns a new *RSA with given private key base64 string
func (*RSA) DecryptWithPrivateKey ¶
DecryptWithPrivateKey decrypts the cipher with private key
func (*RSA) DecryptWithPublicKey ¶
DecryptWithPublicKey decrypts the cipher with public key
func (*RSA) EncryptWithPrivateKey ¶
EncryptWithPrivateKey encrypts the message with private key
func (*RSA) EncryptWithPublicKey ¶
EncryptWithPublicKey encrypts the message with public key
func (*RSA) GetPrivateKey ¶
GetPrivateKey gets the private key base64 string
func (*RSA) GetPublicKey ¶
GetPublicKey gets the public key base64 string
func (*RSA) SetPrivateKey ¶
SetPrivateKey sets the private key with base64 string
func (*RSA) SetPublicKey ¶
SetPublicKey sets the public key with base64 string
type SM2 ¶ added in v0.3.21
type SM2 struct {
// contains filtered or unexported fields
}
func NewSM2WithPrivateKey ¶ added in v0.3.21
func NewSM2WithPrivateKey(privateKey *sm2.PrivateKey) *SM2
NewSM2WithPrivateKey returns a new *SM2 with given private key
func NewSM2WithPrivateKeyHexString ¶ added in v0.3.21
NewSM2WithPrivateKeyString returns a new *SM2 with given private key hex string
func NewSM2WithPublicKey ¶ added in v0.3.21
NewSM2WithPublicKey returns a new *SM2 with given public key
func NewSM2WithPublicKeyHexString ¶ added in v0.3.21
NewSM2WithPublicKeyString returns a new *SM2 with given public key hex string
func (*SM2) DecryptWithPrivateKey ¶ added in v0.3.21
DecryptWithPrivateKey decrypts the data with private key
func (*SM2) EncryptWithPublicKey ¶ added in v0.3.21
EncryptWithPublicKey encrypts the data with public key
func (*SM2) GetPrivateKey ¶ added in v0.3.21
func (s *SM2) GetPrivateKey() *sm2.PrivateKey
GetPrivateKey returns the private key
func (*SM2) GetPrivateKeyHexString ¶ added in v0.3.21
GetPrivateKeyHexString returns the private key hex string
func (*SM2) GetPublicKey ¶ added in v0.3.21
GetPublicKey returns the public key
func (*SM2) GetPublicKeyHexString ¶ added in v0.3.21
GetPublicKeyHexString returns the public key hex string
func (*SM2) SetPrivateKey ¶ added in v0.3.21
func (s *SM2) SetPrivateKey(privateKey *sm2.PrivateKey)
SetPrivateKey sets the private key
func (*SM2) SetPublicKey ¶ added in v0.3.21
SetPublicKey sets the public key