crypto

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt added in v0.2.0

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

Decrypt decrypts a base64-encoded AES-256-GCM ciphertext with the given 32-byte key.

func Encrypt added in v0.2.0

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

Encrypt encrypts plaintext using AES-256-GCM with the given 32-byte key. Returns a base64-encoded ciphertext (nonce prepended).

func GeneratePresignedToken

func GeneratePresignedToken(secretKey, method, bucket, key string, expiresAt time.Time) string

GeneratePresignedToken creates a token for presigned URLs

func GenerateSignature

func GenerateSignature(secretKey, method, path, timestamp string) string

GenerateSignature creates an HMAC-SHA256 signature for a request

func GetEncryptionKey added in v0.2.0

func GetEncryptionKey() []byte

GetEncryptionKey returns the current encryption key.

func HashPassword added in v0.2.0

func HashPassword(password string) (string, error)

HashPassword creates a bcrypt hash of a password (for shareable link passwords).

func HashSecret

func HashSecret(secret string) string

HashSecret creates a SHA-256 hash of a secret key for storage

func IsTimestampValid

func IsTimestampValid(timestamp string) bool

IsTimestampValid checks if a timestamp is within acceptable range (15 minutes)

func SetEncryptionKey added in v0.2.0

func SetEncryptionKey(key []byte)

SetEncryptionKey stores the 32-byte key used for encrypting secrets at rest.

func VerifyPassword added in v0.2.0

func VerifyPassword(password, hash string) bool

VerifyPassword checks if a password matches a bcrypt hash. Also supports legacy SHA-256 hashes for backward compatibility.

func VerifyPresignedToken

func VerifyPresignedToken(secretKey, method, bucket, key string, expiresAt time.Time, token string) bool

VerifyPresignedToken verifies a presigned URL token

func VerifySecret

func VerifySecret(secret, hash string) bool

VerifySecret checks if a secret matches a stored hash

func VerifySignature

func VerifySignature(secretKey, method, path, timestamp, signature string) bool

VerifySignature verifies an HMAC-SHA256 signature

Types

This section is empty.

Jump to

Keyboard shortcuts

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