security

package
v0.0.0-...-858e686 Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PrivateKey = []byte(`
-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQDZsfv1qscqYdy4vY+P4e3cAtmvppXQcRvrF1cB4drkv0haU24Y
7m5qYtT52Kr539RdbKKdLAM6s20lWy7+5C0DgacdwYWd/7PeCELyEipZJL07Vro7
Ate8Bfjya+wltGK9+XNUIHiumUKULW4KDx21+1NLAUeJ6PeW+DAkmJWF6QIDAQAB
AoGBAJlNxenTQj6OfCl9FMR2jlMJjtMrtQT9InQEE7m3m7bLHeC+MCJOhmNVBjaM
ZpthDORdxIZ6oCuOf6Z2+Dl35lntGFh5J7S34UP2BWzF1IyyQfySCNexGNHKT1G1
XKQtHmtc2gWWthEg+S6ciIyw2IGrrP2Rke81vYHExPrexf0hAkEA9Izb0MiYsMCB
/jemLJB0Lb3Y/B8xjGjQFFBQT7bmwBVjvZWZVpnMnXi9sWGdgUpxsCuAIROXjZ40
IRZ2C9EouwJBAOPjPvV8Sgw4vaseOqlJvSq/C/pIFx6RVznDGlc8bRg7SgTPpjHG
4G+M3mVgpCX1a/EU1mB+fhiJ2LAZ/pTtY6sCQGaW9NwIWu3DRIVGCSMm0mYh/3X9
DAcwLSJoctiODQ1Fq9rreDE5QfpJnaJdJfsIJNtX1F+L3YceeBXtW0Ynz2MCQBI8
9KP274Is5FkWkUFNKnuKUK4WKOuEXEO+LpR+vIhs7k6WQ8nGDd4/mujoJBr5mkrw
DPwqA3N5TMNDQVGv8gMCQQCaKGJgWYgvo3/milFfImbp+m7/Y3vCptarldXrYQWO
AQjxwc71ZGBFDITYvdgJM1MTqc8xQek1FXn1vfpy2c6O
-----END RSA PRIVATE KEY-----
`)
View Source
var PublicKey = []byte(`
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDZsfv1qscqYdy4vY+P4e3cAtmv
ppXQcRvrF1cB4drkv0haU24Y7m5qYtT52Kr539RdbKKdLAM6s20lWy7+5C0Dgacd
wYWd/7PeCELyEipZJL07Vro7Ate8Bfjya+wltGK9+XNUIHiumUKULW4KDx21+1NL
AUeJ6PeW+DAkmJWF6QIDAQAB
-----END PUBLIC KEY-----
`)

Functions

func EncodeMD5

func EncodeMD5(value string) string

EncodeMD5 md5 encryption

func ParsePKCS1Or8PrivKey

func ParsePKCS1Or8PrivKey(key []byte) (*rsa.PrivateKey, error)

func ParsePublicKey

func ParsePublicKey(key []byte) (*rsa.PublicKey, error)

ParsePublicKey 解析公钥

func RSADecrypt

func RSADecrypt(ciphertext, privateKey []byte) ([]byte, error)

RSADecrypt RSA 解密

func RSADecryptBase64

func RSADecryptBase64(b64Cipher string, privateKey []byte) ([]byte, error)

RSADecryptBase64 RSA 解密 Base64 密文

func RSAEncrypt

func RSAEncrypt(origData, publicKey []byte) ([]byte, error)

RSAEncrypt RSA 加密

func RSAEncryptBase64

func RSAEncryptBase64(origData, publicKey []byte) (string, error)

RSAEncryptBase64 RSA 加密 Base64 密文

func RSAEncryptDERType

func RSAEncryptDERType(origData, publicDERKey []byte) ([]byte, error)

RSAEncryptDERType RSA加密,密钥是 DER 格式

func RSASign

func RSASign(text []byte, privateKey string, hashType crypto.Hash) ([]byte, error)

RSASign RSA 签名

func RSASignBase64

func RSASignBase64(text []byte, privateKey string, hashType crypto.Hash) (string, error)

RSASign RSA 签名 Base64

func RSAVerifySign

func RSAVerifySign(text []byte, publicKey string, hashType crypto.Hash, sig []byte) error

RSAVerifySign RSA验证签名

func RSAVerifySignBase64

func RSAVerifySignBase64(b64Cipher, publicKey string, hashType crypto.Hash, text []byte) error

RSAVerifySignBase64 RSA验证Base64签名

func SHA256

func SHA256(data []byte) string

SHA256 哈希

func SHA256Sign

func SHA256Sign(httpMethod, url, dateTime, signKey string, body []byte) (string, error)

SHA256Sign 共用的签名算法

func SHA256WithRSA

func SHA256WithRSA(data, privateKey []byte, noneWithRsa bool) ([]byte, error)

SHA256WithRSA SHA256WithRSA签名算法签名

func SHA256WithRSABase64

func SHA256WithRSABase64(data, privateKey []byte) (string, error)

SHA256WithRSABase64 SHA256WithRSA签名算法签名,返回base64编码后的签名

func VerifySHA256WithRSABase64

func VerifySHA256WithRSABase64(origin []byte, b64Sign, publicKey string) error

VerifySHA256WithRSABase64 SHA256WithRSA签名算法验签,如果验签通过,则err 值为 nil

Types

type AESCFBMode

type AESCFBMode struct {
	Key []byte
	Err error
}

AESCFBMode CFB 模式的 AES 加密

func NewAESCFBEncrypt

func NewAESCFBEncrypt(sKey string) *AESCFBMode

NewAESCFBEncrypt 创建AES加密处理对象

func (*AESCFBMode) Decrypt

func (a *AESCFBMode) Decrypt(ct string) string

Decrypt aes 解密

func (*AESCFBMode) Encrypt

func (a *AESCFBMode) Encrypt(pt string) string

Encrypt aesCFBEncrypt aes 加密 对商户敏感信息加密

Jump to

Keyboard shortcuts

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