sym

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: LGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSymKey

func GenerateSymKey(opt crypto.KeyType, key []byte) (crypto.SymmetricKey, error)

GenerateSymKey generates a new aes256 key or 3des key

func PKCS5Padding

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

PKCS5Padding padding with pkcs5

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) ([]byte, error)

PKCS5UnPadding unpadding with pkcs5

func TripleDesDec

func TripleDesDec(key, src []byte) ([]byte, error)

TripleDesDec decryption algorithm implements

func TripleDesEnc

func TripleDesEnc(key, src []byte) ([]byte, error)

TripleDesEnc encryption algorithm implements

Types

type AESKey

type AESKey struct {
	// contains filtered or unexported fields
}

AES a AES instance is a tool to encrypt and decrypt

func (*AESKey) Bytes

func (ek *AESKey) Bytes() ([]byte, error)

Bytes return bytes

func (*AESKey) Decrypt

func (ek *AESKey) Decrypt(crypted []byte) ([]byte, error)

Decrypt decrypt

func (*AESKey) Encrypt

func (ek *AESKey) Encrypt(plain []byte) ([]byte, error)

Encrypt encrypt

func (*AESKey) Type

func (ek *AESKey) Type() crypto.KeyType

type ThirdDESKey

type ThirdDESKey struct {
	// contains filtered or unexported fields
}

TripleDES a 3DES instance is a tool to encrypt and decrypt Very not recommended to use 3des!!! It's slow and unsafe

func (*ThirdDESKey) Bytes

func (ea *ThirdDESKey) Bytes() ([]byte, error)

func (*ThirdDESKey) Decrypt

func (ea *ThirdDESKey) Decrypt(cipherTex []byte) (plaintext []byte, err error)

Decrypt decrypt

func (*ThirdDESKey) Encrypt

func (ea *ThirdDESKey) Encrypt(plain []byte) (cipher []byte, err error)

Encrypt encrypt

func (*ThirdDESKey) Type

func (ea *ThirdDESKey) Type() crypto.KeyType

Jump to

Keyboard shortcuts

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