crypto

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(encrypted string, key []byte) (string, error)

Decrypt decrypts AES-256-GCM ciphertext. Key must be 32 bytes.

func Encrypt

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

Encrypt encrypts plaintext using AES-256-GCM. Key must be 32 bytes.

func HMACSign

func HMACSign(message, key string) string

HMACSign creates an HMAC-SHA256 signature.

func HMACVerify

func HMACVerify(message, signature, key string) bool

HMACVerify checks an HMAC-SHA256 signature (constant-time).

func RandomBase64

func RandomBase64(n int) string

RandomBase64 returns a URL-safe base64-encoded random string.

func RandomBytes

func RandomBytes(n int) ([]byte, error)

RandomBytes returns n cryptographically random bytes.

func RandomHex

func RandomHex(n int) string

RandomHex returns a random hex string of n bytes (2n hex chars).

func SHA256Hash

func SHA256Hash(data string) string

SHA256Hash returns the hex-encoded SHA-256 hash of data.

Types

This section is empty.

Jump to

Keyboard shortcuts

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