crypto

package
v0.0.0-...-5bb0c7b Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2021 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyMustBePEMEncoded = errors.New("Invalid Key: Key must be PEM encoded PKCS1 or PKCS8 private key")
	ErrNotRSAPrivateKey    = errors.New("Key is not a valid RSA private key")
)
View Source
var (
	EmptyAESIV = []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
)
View Source
var (
	EmptyDesIV = []byte{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
)

Functions

func AESDecryptCBC

func AESDecryptCBC(src []byte, key []byte, iv []byte) (dst []byte, err error)

func AESDecryptCTR

func AESDecryptCTR(src []byte, key []byte, iv []byte) (dst []byte, err error)

func AESDecryptGCM

func AESDecryptGCM(cipherText []byte, key [32]byte) (plaintext []byte, err error)

func AESEncryptCBC

func AESEncryptCBC(src []byte, key []byte, iv []byte) (dst []byte, err error)

func AESEncryptCTR

func AESEncryptCTR(src []byte, key []byte, iv []byte) (dst []byte, err error)

func AESEncryptGCM

func AESEncryptGCM(data []byte, key [32]byte) ([]byte, error)

func DesDecrypt

func DesDecrypt(cipherText, key []byte) ([]byte, error)

func DesEncrypt

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

encrypt string to base64 crypto using des

func GetSha1Hash

func GetSha1Hash(s string) string

func GetSha256Hash

func GetSha256Hash(s string) string

func GetSha384Hash

func GetSha384Hash(s string) string

func HmacSha1

func HmacSha1(source, secret string) string

func NewKey

func NewKey(salt, password []byte) [32]byte

func ParseRSAPrivateKeyFromPEM

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

func ParseRSAPublicKey

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

func ParseRSAPublicKeyFromPEM

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

func Pkcs5Padding

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

func Pkcs5UnPadding

func Pkcs5UnPadding(src []byte) []byte

func Pkcs7Padding

func Pkcs7Padding(data []byte, blocklen int) ([]byte, error)

func Pkcs7UnPadding

func Pkcs7UnPadding(data []byte, blocklen int) ([]byte, error)

func RSA256Sign

func RSA256Sign(privateKey *rsa.PrivateKey, data []byte) (string, error)

func RSA256Verify

func RSA256Verify(pubKey *rsa.PublicKey, data []byte, sign string) error

func RSADecrypt

func RSADecrypt(privateKey *rsa.PrivateKey, data []byte) ([]byte, error)

func RSAEncrypt

func RSAEncrypt(pubKey *rsa.PublicKey, data []byte) ([]byte, error)

func RSASign

func RSASign(privateKey *rsa.PrivateKey, data []byte) (string, error)

func RSAVerify

func RSAVerify(pubKey *rsa.PublicKey, data []byte, sign string) error

Types

type Data

type Data []byte

func (Data) GetMd5

func (d Data) GetMd5() []byte

func (Data) GetMd5String

func (d Data) GetMd5String() string

type String

type String string

func (String) GetMd5

func (d String) GetMd5() []byte

func (String) GetMd5String

func (d String) GetMd5String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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