Documentation
¶
Index ¶
- func Decrypt(encoded string, key []byte) (string, error)
- func Encrypt(plaintext string, key []byte) (string, error)
- func GeneratePresignedToken(secretKey, method, bucket, key string, expiresAt time.Time) string
- func GenerateSignature(secretKey, method, path, timestamp string) string
- func GetEncryptionKey() []byte
- func HashPassword(password string) (string, error)
- func HashSecret(secret string) string
- func IsTimestampValid(timestamp string) bool
- func SetEncryptionKey(key []byte)
- func VerifyPassword(password, hash string) bool
- func VerifyPresignedToken(secretKey, method, bucket, key string, expiresAt time.Time, token string) bool
- func VerifySecret(secret, hash string) bool
- func VerifySignature(secretKey, method, path, timestamp, signature string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decrypt ¶ added in v0.2.0
Decrypt decrypts a base64-encoded AES-256-GCM ciphertext with the given 32-byte key.
func Encrypt ¶ added in v0.2.0
Encrypt encrypts plaintext using AES-256-GCM with the given 32-byte key. Returns a base64-encoded ciphertext (nonce prepended).
func GeneratePresignedToken ¶
GeneratePresignedToken creates a token for presigned URLs
func GenerateSignature ¶
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
HashPassword creates a bcrypt hash of a password (for shareable link passwords).
func HashSecret ¶
HashSecret creates a SHA-256 hash of a secret key for storage
func IsTimestampValid ¶
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
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 ¶
VerifySecret checks if a secret matches a stored hash
func VerifySignature ¶
VerifySignature verifies an HMAC-SHA256 signature
Types ¶
This section is empty.