crypto

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2023 License: MIT Imports: 15 Imported by: 0

README

crypto

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Md5 added in v1.0.2

func Md5(src interface{}) string

对字符串进行md5哈希算法

func Sha1 added in v1.0.2

func Sha1(src interface{}) string

对字符串进行sha1哈希算法

Types

type AES

type AES struct {
	Key []byte // 密钥
}

func (*AES) Decrypt

func (s *AES) Decrypt(src interface{}) []byte

解密

func (*AES) Encrypt

func (s *AES) Encrypt(src interface{}) string

加密

type RSA added in v1.0.1

type RSA struct {
	PrivateKey *rsa.PrivateKey
	PublicKey  *rsa.PublicKey
}

func (*RSA) Decrypt added in v1.0.1

func (s *RSA) Decrypt(ciphertext string) (string, error)

func (*RSA) Encrypt added in v1.0.1

func (s *RSA) Encrypt(plainText string) (string, error)

func (*RSA) GenerateKey added in v1.0.1

func (s *RSA) GenerateKey() error

GenerateKey RSA private/public key

func (*RSA) GenerateKeyBase64 added in v1.0.1

func (s *RSA) GenerateKeyBase64(priv *rsa.PrivateKey, pub *rsa.PublicKey) (string, string, error)

GenerateKeyBase64 generate RSA key to string Compared with GenerateKeyBuffer this output:

  1. Have no header/tailer line
  2. Key content is merged into one-line format

func (*RSA) GenerateKeyBuffer added in v1.0.1

func (s *RSA) GenerateKeyBuffer(priv *rsa.PrivateKey, pub *rsa.PublicKey) (string, string, error)

GenerateKeyBuffer generate RSA key to Memory

func (*RSA) GenerateKeyFile added in v1.0.1

func (s *RSA) GenerateKeyFile(privFileName, pubFileName string) error

GenerateKeyFile generate RSA key file

func (*RSA) GenerateKeyPrivBase64 added in v1.0.1

func (s *RSA) GenerateKeyPrivBase64(priv *rsa.PrivateKey) (string, error)

func (*RSA) GenerateKeyPubBase64 added in v1.0.1

func (s *RSA) GenerateKeyPubBase64(pub *rsa.PublicKey) (string, error)

func (*RSA) LoadKeyBase64 added in v1.0.1

func (s *RSA) LoadKeyBase64(privString string) error

LoadKeyBase64 from string load key

func (*RSA) LoadkeyFile added in v1.0.1

func (s *RSA) LoadkeyFile(privFileName string) error

LoadkeyFile from file load key

func (*RSA) Sign added in v1.0.1

func (s *RSA) Sign(src []byte) (string, error)

Sign is

func (*RSA) Verify added in v1.0.1

func (s *RSA) Verify(src []byte, sign []byte) error

Verify is

Jump to

Keyboard shortcuts

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