crypto

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PUB_PEM_BEGIN = "-----BEGIN PUBLIC KEY-----"
	PUB_PEM_END   = "-----END PUBLIC KEY-----"

	PRIV_PEM_BEGIN = "-----BEGIN PRIVATE KEY-----"
	PRIV_PEM_END   = "-----END PRIVATE KEY-----"

	ErrDecodePemFailed = errors.New("failed to decode public key pem")
	ErrInvalidKey      = errors.New("invalid key")
)

Functions

func AesEcbDecrypt added in v0.1.1

func AesEcbDecrypt(secret []byte, s string) (string, error)

AES/ECB/PKCSPadding decode hex string and decrypt.

func AesEcbEncrypt added in v0.1.1

func AesEcbEncrypt(secret []byte, plain string) (string, error)

AES/ECB/PKCSPadding encrypt and encoded as hex string.

func LoadPrivKey

func LoadPrivKey(content string) (*rsa.PrivateKey, error)

func LoadPubKey

func LoadPubKey(content string) (*rsa.PublicKey, error)

func NewECBDecrypter added in v0.1.1

func NewECBDecrypter(b cipher.Block) cipher.BlockMode

ECB block mode for decryption.

func NewECBEncrypter added in v0.1.1

func NewECBEncrypter(b cipher.Block) cipher.BlockMode

ECB block mode for encryption.

func PKCSPadding added in v0.1.1

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

PKCS5/7 Padding

func PKCSTrimming added in v0.1.1

func PKCSTrimming(encrypt []byte) []byte

PKCS5/7 Trimming

Types

type ECBDecrypter added in v0.1.1

type ECBDecrypter ecb

func (*ECBDecrypter) BlockSize added in v0.1.1

func (ec *ECBDecrypter) BlockSize() int

func (*ECBDecrypter) CryptBlocks added in v0.1.1

func (ec *ECBDecrypter) CryptBlocks(dst, src []byte)

type ECBEncrypter added in v0.1.1

type ECBEncrypter ecb

func (*ECBEncrypter) BlockSize added in v0.1.1

func (ec *ECBEncrypter) BlockSize() int

func (*ECBEncrypter) CryptBlocks added in v0.1.1

func (ec *ECBEncrypter) CryptBlocks(dst, src []byte)

Jump to

Keyboard shortcuts

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