cryptz

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AESCBCDecrypt added in v0.0.2

func AESCBCDecrypt(dst, cipherText, key, iv []byte) (int, error)

AESCBCDecrypt decrypts encryptText with key and iv key length must be 16, 24 or 32 bytes to select AES-128, AES-192 or AES-256. iv length must be 16 bytes, iv should be random to ensure safety dst could reuse encryptText memory

func AESCBCDecryptLen added in v0.0.2

func AESCBCDecryptLen[T typez.StrOrBytes](cipherText T) int

AESCBCDecryptLen returns the length of the decrypted data

func AESCBCEncrypt added in v0.0.2

func AESCBCEncrypt(dst, plainText, key, iv []byte) error

AESCBCEncrypt encrypts plainText with key and iv key length must be 16, 24 or 32 bytes to select AES-128, AES-192 or AES-256. iv length must be 16 bytes, iv should be random to ensure safety plainText could pre grow padding length, so dst could reuse plainText memory

func AESCBCEncryptLen added in v0.0.2

func AESCBCEncryptLen[T typez.StrOrBytes](plainText T) int

AESCBCEncryptLen returns the length of the encrypted data

func AESGCMDecrypt added in v0.0.2

func AESGCMDecrypt(dst, cipherText, key, nonce, additionalData []byte) error

AESGCMDecrypt decrypts encryptText with key and additionalData key length must be 16, 24 or 32 bytes to select AES-128, AES-192 or AES-256. dst could reuse encryptText memory, like encryptText[:AESGCMDecryptLen(encryptText)]

func AESGCMDecryptLen added in v0.0.2

func AESGCMDecryptLen[T typez.StrOrBytes](cipherText T) int

AESGCMDecryptLen returns the length of the decrypted data

func AESGCMEncrypt added in v0.0.2

func AESGCMEncrypt(dst, plainText, key, nonce, additionalData []byte) error

AESGCMEncrypt encrypts plainText with key and additionalData key length must be 16, 24 or 32 bytes to select AES-128, AES-192 or AES-256. plainText could pre grow tagSize(default 16) so dst could reuse plainText memory

func AESGCMEncryptLen added in v0.0.2

func AESGCMEncryptLen[T typez.StrOrBytes](plainText T) int

AESGCMEncryptLen returns the length of the encrypted data

func Decrypt

func Decrypt[T, E typez.StrOrBytes](cipherText T, secret E) ([]byte, error)

Decrypt decrypts cipherText with secret (openssl aes-256-cbc implementation).

func DecryptStreamTo

func DecryptStreamTo[E typez.StrOrBytes](out io.Writer, stream io.Reader, secret E) error

DecryptStreamTo decrypts stream to out with secret

func Encrypt

func Encrypt[T, E typez.StrOrBytes](plainText T, secret E) ([]byte, error)

Encrypt encrypts plainText with secret (openssl aes-256-cbc implementation).

func EncryptStreamTo

func EncryptStreamTo[E typez.StrOrBytes](out io.Writer, stream io.Reader, secret E) error

EncryptStreamTo encrypts stream to out with secret

func GCMDecrypt added in v0.0.2

func GCMDecrypt[T, E, D typez.StrOrBytes](cipherText T, secret E, additionalData D) ([]byte, error)

GCMDecrypt decrypts cipherText with secret and additionalData

func GCMEncrypt added in v0.0.2

func GCMEncrypt[T, E, D typez.StrOrBytes](plainText T, secret E, additionalData D) ([]byte, error)

GCMEncrypt encrypts plainText with secret and additionalData

func PKCS5Padding

func PKCS5Padding(data []byte) ([]byte, error)

PKCS5Padding adds padding to the input data according to the PKCS#5 standard

func PKCS5UnPadding

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

PKCS5UnPadding removes padding from the input data according to the PKCS#5 standard

func PKCS7Padding

func PKCS7Padding(data []byte, blockSize int) ([]byte, error)

PKCS7Padding adds padding to the input data according to the PKCS#7 standard

func PKCS7UnPadding

func PKCS7UnPadding(data []byte, blockSize int) ([]byte, error)

PKCS7UnPadding removes padding from the input data according to the PKCS#7 standard

func SaltBySecretCBCDecrypt added in v0.0.8

func SaltBySecretCBCDecrypt[E typez.StrOrBytes](cipherText []byte, secret E, reuseCipherText bool) ([]byte, error)

SaltBySecretCBCDecrypt

func SaltBySecretCBCEncrypt added in v0.0.8

func SaltBySecretCBCEncrypt[T, E typez.StrOrBytes](plainText T, secret E) ([]byte, error)

SaltBySecretCBCEncrypt

func SaltBySecretGCMDecrypt added in v0.0.8

func SaltBySecretGCMDecrypt[E, D typez.StrOrBytes](cipherText []byte, secret E, additionalData D, reuseCipherText bool) ([]byte, error)

SaltBySecretGCMDecrypt

func SaltBySecretGCMEncrypt added in v0.0.8

func SaltBySecretGCMEncrypt[T, E, D typez.StrOrBytes](plainText T, secret E, additionalData D) ([]byte, error)

SaltBySecretGCMEncrypt

Types

This section is empty.

Jump to

Keyboard shortcuts

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