crypto

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPadding = errors.New("invalid PKCS7 padding")
)

Functions

func AesDecrypt

func AesDecrypt(ciphertext []byte, key []byte) ([]byte, error)

AesDecrypt decrypts AES-CFB ciphertext produced by AesEncrypt.

func AesDecrypt64

func AesDecrypt64(encodedCiphertext string, key []byte) ([]byte, error)

AesDecrypt64 - AES Decrypt base64

func AesEncrypt

func AesEncrypt(plaintext []byte, key []byte) ([]byte, error)

AesEncrypt encrypts plaintext with AES-CFB. Prefer AesGCMEncrypt for new code because CFB does not authenticate ciphertext integrity.

func AesEncrypt64

func AesEncrypt64(plaintext []byte, key []byte) (string, error)

AesEncrypt64 - AES Encrypt base64

func AesGCMDecrypt added in v0.2.5

func AesGCMDecrypt(ciphertext []byte, key []byte) ([]byte, error)

AesGCMDecrypt decrypts and authenticates data produced by AesGCMEncrypt.

func AesGCMDecrypt64 added in v0.2.5

func AesGCMDecrypt64(encodedCiphertext string, key []byte) ([]byte, error)

AesGCMDecrypt64 decrypts base64 data produced by AesGCMEncrypt64.

func AesGCMEncrypt added in v0.2.5

func AesGCMEncrypt(plaintext []byte, key []byte) ([]byte, error)

AesGCMEncrypt encrypts and authenticates plaintext with AES-GCM. The returned byte slice is nonce || ciphertext || tag.

func AesGCMEncrypt64 added in v0.2.5

func AesGCMEncrypt64(plaintext []byte, key []byte) (string, error)

AesGCMEncrypt64 encrypts and authenticates plaintext, returning base64 data.

func ComparePassword

func ComparePassword(hashedPassword, password string) bool

ComparePassword compares the hashed password with the provided password.

func HashPassword

func HashPassword(ctx context.Context, password string) (string, error)

HashPassword hashes the provided password using bcrypt.

func PKCS7Padding

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

PKCS7Padding - PKCS7 padding

func PKCS7UnPadding

func PKCS7UnPadding(origData []byte) []byte

PKCS7UnPadding - PKCS7 unpadding

func PKCS7UnPaddingE added in v0.2.5

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

PKCS7UnPaddingE removes PKCS7 padding and validates the padding bytes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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