crypto

package
v0.0.0-...-585f190 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthKeys

type AuthKeys struct {
	Pri  string
	Pub  string
	Seed string
}

type AuthSeed

type AuthSeed struct {
	Seed int64  `json:"seed"`
	Key  string `json:"key"`
}

type UsersAuth

type UsersAuth struct {
	// contains filtered or unexported fields
}

func NewUsersAuth

func NewUsersAuth(conf *config.Config) *UsersAuth

func (UsersAuth) DecryptWithPrivateKey

func (a UsersAuth) DecryptWithPrivateKey(ciphertext []byte, privKey *rsa.PrivateKey) (string, error)

基于私钥解密

func (UsersAuth) EncryptAES

func (a UsersAuth) EncryptAES(key []byte, plaintext string) (string, error)

func (UsersAuth) EncryptWithPublicKey

func (a UsersAuth) EncryptWithPublicKey(msg string, pubKey *rsa.PublicKey) ([]byte, error)

基于公钥加密

func (UsersAuth) GenerateAuthSeed

func (a UsersAuth) GenerateAuthSeed(aesKey string) (string, error)

func (UsersAuth) GenerateKeys

func (a UsersAuth) GenerateKeys(bits int) (*rsa.PrivateKey, *rsa.PublicKey, error)

生成密钥对

func (UsersAuth) GenerateRandPasswd

func (a UsersAuth) GenerateRandPasswd() (string, error)

func (UsersAuth) GenerateRandSeed

func (a UsersAuth) GenerateRandSeed() int64

func (UsersAuth) LoadPrivateKey

func (a UsersAuth) LoadPrivateKey(path string) (*rsa.PrivateKey, error)

loadPrivateKey 从文件中加载 RSA 私钥

func (UsersAuth) RSADecrypt

func (a UsersAuth) RSADecrypt(ciphertext string) ([]byte, error)

rsaDecrypt 使用 RSA 私钥解密数据

Jump to

Keyboard shortcuts

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