Documentation
¶
Overview ¶
Package symmetry provides symmetric cryptographic helpers for hashing, AES-GCM encryption, and Fernet-compatible tokens.
Index ¶
- func Blake3(message string) string
- func DecodeFernet(keyString, encryptedString string) (string, error)
- func DecryptAES(symmetricalAccess, valorCifrado, additionalData string) (string, error)
- func EncodeFernet(keyString, originalString string) (string, error)
- func EncryptAES(symmetricalAccess, valorCampo, additionalData string) (string, error)
- func GenerateHMAC(message, secretKey string) string
- func Sha256Hex(message string) string
- func ValidateHMAC(message, secretKey, providedHash string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeFernet ¶
DecodeFernet validates and decrypts a standard Fernet token.
It verifies the token structure, validates the HMAC-SHA256 signature, decrypts the ciphertext with AES-128-CBC, removes PKCS#7 padding, and returns the original plaintext.
func DecryptAES ¶
DecryptAES decrypts payloads produced by EncryptAES using AES-GCM.
func EncodeFernet ¶
EncodeFernet creates a standard Fernet token compatible with common Fernet implementations.
keyString must decode to exactly 32 bytes. The token includes version, timestamp, IV, AES-128-CBC ciphertext, and an HMAC-SHA256 signature, and is returned as URL-safe Base64.
func EncryptAES ¶
EncryptAES encrypts valorCampo using AES-GCM and returns a Base64 payload with this layout:
Base64( nonce | ciphertext_and_tag )
symmetricalAccess must be a Base64-encoded AES key whose decoded size is 16, 24, or 32 bytes.
func GenerateHMAC ¶
GenerateHMAC computes an HMAC-SHA256 for message using secretKey and returns the digest encoded as standard Base64.
func ValidateHMAC ¶
ValidateHMAC reports whether providedHash matches the HMAC-SHA256 generated from message and secretKey.
Types ¶
This section is empty.