cryptos

package module
v0.0.0-...-26acfe3 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2020 License: MIT Imports: 25 Imported by: 0

README

cryptos

常用密码学相关封装

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InvalidECDSAPublicKey  = errors.New("invalid ecdsa public key")
	InvalidECDSAPrivateKey = errors.New("invalid ecdsa private key")
	ECDSAVerifyFailed      = errors.New("ecdsa ecdsa verify failed")
)
View Source
var (
	InvalidRSAPublicKey  = errors.New("invalid rsa public key")
	InvalidRSAPrivateKey = errors.New("invalid rsa private key")
)

Functions

func AesCBCDecryptByPKCS5UnPadding

func AesCBCDecryptByPKCS5UnPadding(data, secret []byte) ([]byte, error)

func AesCBCDecryptByPKCS7UnPadding

func AesCBCDecryptByPKCS7UnPadding(data, secret []byte) ([]byte, error)

func AesCBCEncryptByPKCS5Padding

func AesCBCEncryptByPKCS5Padding(data, secret []byte) ([]byte, error)

func AesCBCEncryptByPKCS7Padding

func AesCBCEncryptByPKCS7Padding(data, secret []byte) ([]byte, error)

func AesCFBDecrypt

func AesCFBDecrypt(data, secret []byte) ([]byte, error)

func AesCFBEncrypt

func AesCFBEncrypt(data, secret []byte) ([]byte, error)

func AesPKCS5Padding

func AesPKCS5Padding(src []byte, blockSize int) []byte

PKCS5 Padding

func AesPKCS5UnPadding

func AesPKCS5UnPadding(src []byte) []byte

PKCS5 Padding

func AesPKCS7Padding

func AesPKCS7Padding(cipherText []byte, blockSize int) []byte

PKCS7 Padding

func AesPKCS7UnPadding

func AesPKCS7UnPadding(plantText []byte) []byte

PKCS7 Padding

func Base64Decrypt

func Base64Decrypt(data string) ([]byte, error)

func Base64Encrypt

func Base64Encrypt(data []byte) string

func ECDSAGenerate

func ECDSAGenerate(c elliptic.Curve, privateHeaders, publicHeaders map[string]string) (private, public []byte, err error)

func ECDSAParsePrivateKey

func ECDSAParsePrivateKey(secret []byte) (*ecdsa.PrivateKey, error)

func ECDSAParsePublicKey

func ECDSAParsePublicKey(secret []byte) (*ecdsa.PublicKey, error)

func ECDSASignature

func ECDSASignature(hash crypto.Hash, private, data []byte) (r, s *big.Int, err error)

func ECDSAVerify

func ECDSAVerify(hash crypto.Hash, r, s *big.Int, public, data []byte) error

func Hash

func Hash(data []byte, hash crypto.Hash) []byte

func HashHex

func HashHex(data []byte, hash crypto.Hash) string

func HmacHash

func HmacHash(data, secret []byte, hash crypto.Hash) string

Hmac-Sha

func HmacSha1

func HmacSha1(data, secret []byte) string

Hmac-Sha1

func HmacSha256

func HmacSha256(data, secret []byte) string

Hmac-Sha256

func HmacSha512

func HmacSha512(data, secret []byte) string

Hmac-Sha512

func MD5

func MD5(data []byte) []byte

func MD5For16Hex

func MD5For16Hex(data []byte) string

func MD5Hex

func MD5Hex(data []byte) string

func RSAAddBlockType

func RSAAddBlockType(src, blockType string) string

为密钥文件内容添加BlockType

func RSAFormat

func RSAFormat(src string, buffer *bytes.Buffer)

格式话密钥文件 主要是读取的时候不换行的话,会在pem.Decode()的时候出现密钥不通过

func RSAPKCS1Decrypt

func RSAPKCS1Decrypt(private, data []byte) ([]byte, error)

func RSAPKCS1Generate

func RSAPKCS1Generate(bits int, privateHeaders, publicHeaders map[string]string) (private, public []byte, err error)

func RSAPKCS1SegmentDecrypt

func RSAPKCS1SegmentDecrypt(private, data []byte) ([]byte, error)

私钥分段解密

func RSAPKCS1Signature

func RSAPKCS1Signature(hash crypto.Hash, private, data []byte) ([]byte, error)

func RSAPKCS1v15Encrypt

func RSAPKCS1v15Encrypt(public, data []byte) ([]byte, error)

func RSAPKCS1v15SegmentEncrypt

func RSAPKCS1v15SegmentEncrypt(secret, data []byte) ([]byte, error)

公钥分段加密

func RSAPKCS1v15Signature

func RSAPKCS1v15Signature(hash crypto.Hash, private *rsa.PrivateKey, data []byte) ([]byte, error)

func RSAPKCS1v15Verify

func RSAPKCS1v15Verify(hash crypto.Hash, public, data, sign []byte) error

func RSAPKCS8Decrypt

func RSAPKCS8Decrypt(private, data []byte) ([]byte, error)

func RSAPKCS8Generate

func RSAPKCS8Generate(bits int, privateHeaders, publicHeaders map[string]string) (private, public []byte, err error)

func RSAPKCS8SegmentDecrypt

func RSAPKCS8SegmentDecrypt(public, data []byte) ([]byte, error)

私钥分段解密

func RSAPKCS8Signature

func RSAPKCS8Signature(hash crypto.Hash, private, data []byte) ([]byte, error)

func RSAParsePKCS1PrivateKey

func RSAParsePKCS1PrivateKey(private []byte) (*rsa.PrivateKey, error)

func RSAParsePKCS8PrivateKey

func RSAParsePKCS8PrivateKey(private []byte) (*rsa.PrivateKey, error)

func RSAParsePKIXPublicKey

func RSAParsePKIXPublicKey(public []byte) (*rsa.PublicKey, error)

func Sha1

func Sha1(data []byte) []byte

func Sha1Hex

func Sha1Hex(data []byte) string

func Sha256

func Sha256(data []byte) []byte

func Sha256Hex

func Sha256Hex(data []byte) string

func Sha512

func Sha512(data []byte) []byte

func Sha512Hex

func Sha512Hex(data []byte) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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