std

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2022 License: AGPL-3.0 Imports: 28 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildSecretKey

func BuildSecretKey(keyValue string) string

*

  • 生成指定字符串的对称密码

func BytePrivateKey

func BytePrivateKey(privateKey interface{}, password []byte, byteType string) []byte

func BytePublicKey

func BytePublicKey(pubkey interface{}) []byte

func DecodeBase64

func DecodeBase64(cipherText string) []byte

func DecodeHexUpper

func DecodeHexUpper(str string) []byte

16进制字符串转换成byte

func Decrypt

func Decrypt(privateKey interface{}, ciphertext []byte) []byte

*

  • 非对称解密 *
  • @param privkey 解密的密钥
  • @param ciphertext 已经加密的数据
  • @return 解密后的明文
  • @throws EncryptException

func DecryptKey

func DecryptKey(keyValue []byte, privateKey interface{}) []byte

func DecryptSymmetrical

func DecryptSymmetrical(key []byte, ciphertext []byte, mode string) []byte

*

  • 对称解密 *
  • @param key 解密的密钥
  • @param raw 已经加密的数据
  • @return 解密后的明文
  • @throws EncryptException

func EncodeBase64

func EncodeBase64(raw []byte) string

func EncodeHex

func EncodeHex(data []byte) string

16进制转换字符串

func EncodeHmac

func EncodeHmac(data, key []byte, mode string) []byte

Hmac-sha256加密

func Encrypt

func Encrypt(publicKey interface{}, plaintext []byte) []byte

*

  • 非对称加密 *
  • @param key 加密的密钥
  • @param data 待加密的明文数据
  • @return 加密后的数据
  • @throws EncryptException

func EncryptKey

func EncryptKey(key []byte, publicKey interface{}) []byte

* 对对称密钥用对方公钥加密

func EncryptSymmetrical

func EncryptSymmetrical(key []byte, plaintext []byte, mode string) []byte

*

  • 对称加密 *
  • @param key 加密的密钥 The key argument should be the AES key, either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256
  • @param data 待加密的明文数据
  • @return 加密后的数据
  • @throws EncryptException

func GenerateCert

func GenerateCert(parent *x509.Certificate, notBefore time.Time, notAfter time.Time, subject *pkix.Name, password string, keyPair *ecdsa.PrivateKey) *pem.Block

*

  • 根据用户名和密钥对生成 X509 证书 * *
  • @param user
  • @param keyPair
  • @return

func GenerateKeyPair

func GenerateKeyPair(keyType string) interface{}

*

  • 生成非对称的密钥对 *
  • @return

func GenerateSecretKey

func GenerateSecretKey(length int) string

*

  • 生成随机对称秘钥 *
  • @param algorithm
  • @return
  • @throws NoSuchAlgorithmException

func GetPrivateKey

func GetPrivateKey(keyPair interface{}, password string, pos int) interface{}

func GetPublicKey

func GetPublicKey(keyPair interface{}) crypto.PublicKey

func Hash

func Hash(plaintext string, mode string) []byte

获取hash加密字符串

func LoadCert

func LoadCert(buf []byte, password string) *x509.Certificate

func LoadPrivateKey

func LoadPrivateKey(keyValue []byte, password string, byteType string) interface{}

*

  • 从证书中的私钥二进制字符串表示中还原私钥 * *
  • @param keyValue
  • @return

func LoadPublicKey

func LoadPublicKey(keyValue []byte, byteType string) interface{}

*

  • 从公钥字符串表示中还原公钥 * *
  • @param keyValue
  • @return
  • @throws NoSuchAlgorithmException
  • @throws InvalidKeySpecException

func ReadPEMFile

func ReadPEMFile(fileName string) *pem.Block

func ReadSecretKey

func ReadSecretKey(keyValue []byte, privateKey interface{}) []byte

func Sign

func Sign(privateKey *ecdsa.PrivateKey, plaintext string) ([]byte, []byte)

func ValidateKey

func ValidateKey(keypair *ecdsa.PrivateKey) bool

func Verify

func Verify(publicKey *ecdsa.PublicKey, plaintext string, rtext, stext []byte) bool

func WritePEMFile

func WritePEMFile(fileName string, block *pem.Block)

func WritePrivateKey

func WritePrivateKey(privateKey interface{}, password []byte, byteType string) string

func WritePublicKey

func WritePublicKey(publicKey interface{}) string

func WriteSecretKey

func WriteSecretKey(key []byte, publicKey *ecdsa.PublicKey) []byte

* 对对称密钥用对方公钥加密

Types

This section is empty.

Jump to

Keyboard shortcuts

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