crypto

package module
v0.0.0-...-38d2717 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2018 License: Apache-2.0 Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIllegalParameter = errors.New("illegal parameter(s)")
	ErrDataLen          = errors.New("data length error")
	ErrDecryption       = errors.New("decryption error")
	ErrDataBroken       = errors.New("data broken, first byte is not zero")
	ErrDataToLarge      = errors.New("data is too large (len > 128) ")
	ErrKeyPairDismatch  = errors.New("data is not encrypted by the private key")
)

Functions

func BuildQuery

func BuildQuery(params map[string]string) string

func DecryptBase64

func DecryptBase64(data string) []byte

DecryptBase64 decrypt given string with Base64 algorithm

func DesCBCDecrypt

func DesCBCDecrypt(crypted, key []byte) ([]byte, error)

func DesCBCEncrypt

func DesCBCEncrypt(origData, key []byte) ([]byte, error)

func DesECBDecrypt

func DesECBDecrypt(data, key []byte) ([]byte, error)

func DesECBEncrypt

func DesECBEncrypt(data, key []byte) ([]byte, error)

func EncryptBase64

func EncryptBase64(data []byte) string

EncryptBase64 encrypt given []byte with Base64 algorithm

func EncryptMD5

func EncryptMD5(data []byte) []byte

EncryptMD5 encrypt given []byte with MD5 algorithm

func EncryptSHA

func EncryptSHA(data []byte) []byte

EncryptSHA encrypt given []byte with SHA algorithm

func MarshalPKCS8PrivateKey

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

pkcs1 to pkcs8

func PKCS5Padding

func PKCS5Padding(ciphertext []byte, blockSize int) []byte

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

func PfxEncryptRSA

func PfxEncryptRSA(data []byte, pfxStr string, pfxPwd string) ([]byte, error)

Pfx EncryptRSA encrypt given data with RSA algorithm pfx加密

func PrivateDecryptRSA

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

DecryptRSA decrypt given []byte with RSA algorithm 私钥加密

func PrivateEncryptRSA

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

private EncryptRSA encrypt given data with RSA algorithm 私钥加密

func PublicDecryptRSA

func PublicDecryptRSA(data []byte, publicKey string) ([]byte, error)

Public DecryptRSA decrypt given data with RSA algorithm 公钥解密

func PublicEncryptRSA

func PublicEncryptRSA(data []byte, publicKey string) ([]byte, error)

public EncryptRSA encrypt given data with RSA algorithm 公钥加密

func RsaPrivateKeyPkcs1ToPkcs8

func RsaPrivateKeyPkcs1ToPkcs8(privateKey []byte) ([]byte, error)

rsa privatekey format pkcs1 transform to pkcs8 mode

func SignRSA

func SignRSA(raw []byte, algorithm crypto.Hash, privateKey string) []byte

SignWithRSA sign given encrypted data with RSA algorithm

func VerifySignature

func VerifySignature(raw []byte, signature string, algorithm crypto.Hash, publicKey string) bool

VerifySignature verify whether the given signature is correct

Types

This section is empty.

Jump to

Keyboard shortcuts

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