Documentation
¶
Overview ¶
Package cryptoutils implements cryptographic primitives used by netcap for secure communication between distributed components. It wraps the NaCl box construction for authenticated public-key encryption and provides utilities for hashing and random token generation.
Index ¶
- Constants
- func AsymmetricDecrypt(sealed []byte, senderPub, recipientPriv *[KeySize]byte) ([]byte, bool)
- func AsymmetricEncrypt(message []byte, recipientPub, senderPriv *[KeySize]byte) ([]byte, error)
- func GenerateKeypair() (pub, priv *[KeySize]byte, err error)
- func MD5Data(input []byte) []byte
- func RandomString(n int) (string, error)
Constants ¶
const (
// KeySize represents the byte length of Curve25519 keys.
KeySize = 32
)
Curve25519 key dimensions used by NaCl box.
Variables ¶
This section is empty.
Functions ¶
func AsymmetricDecrypt ¶
AsymmetricDecrypt reverses AsymmetricEncrypt, verifying authenticity and recovering the original plaintext. Returns (nil, false) on failure.
func AsymmetricEncrypt ¶
AsymmetricEncrypt secures plaintext using NaCl box (Curve25519 + XSalsa20 + Poly1305). The recipient's public key and sender's private key authenticate the message. Output format: [24-byte nonce][ciphertext with 16-byte auth tag]
func GenerateKeypair ¶
GenerateKeypair produces a fresh Curve25519 key pair suitable for use with the NaCl box authenticated encryption scheme.
func MD5Data ¶
MD5Data computes the MD5 digest of the input bytes. Note: MD5 is used here only for non-cryptographic checksums (e.g., file integrity).
func RandomString ¶
RandomString produces a URL-safe random string of exactly n characters. Uses base64url encoding of cryptographically random bytes.
Types ¶
This section is empty.