Documentation ¶
Overview ¶
Package encryption provides functionalities for secure message encryption using the NaCl (Networking and Cryptography library) authenticated encryption scheme.
It includes methods for encrypting messages, handling version information, and verifying the validity of version strings.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type EncryptedMessage ¶
type EncryptedMessage struct { Version Version `json:"version"` Nonce []byte `json:"nonce"` EphemeralPublicKey []byte `json:"ephemPublicKey"` Ciphertext []byte `json:"ciphertext"` }
EncryptedMessage represents an encrypted message with additional meta-information.
func Encrypt ¶
func Encrypt(encryptionKey [32]byte, message []byte) (EncryptedMessage, error)
Encrypt encrypts a message using VersionNaClAuthenticated encryption version.
func EncryptWithPadding ¶
func EncryptWithPadding(encryptionKey [32]byte, message any) (EncryptedMessage, error)
EncryptWithPadding encrypts a message in a way that obscures the message length.
The message is padded to a multiple of 2048 before being encrypted so that the length of the resulting encrypted message can't be used to guess the exact length of the original message.
type Version ¶
type Version string
Version represents a string that indicates the set of used cryptography algorithms.
const VersionNaClAuthenticated Version = "x25519-xsalsa20-poly1305"
VersionNaClAuthenticated uses Curve25519, XSalsa20 and Poly1305 to encrypt and authenticate messages.
func (Version) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*Version) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.