Documentation
¶
Index ¶
- Constants
- func Decrypt(data, key []byte) ([]byte, error)
- func DecryptAuto(ciphertext, key []byte) ([]byte, error)
- func DecryptFile(ciphertext []byte, key []byte) ([]byte, error)
- func DecryptStream(ciphertext, key []byte) ([]byte, error)
- func Encrypt(plaintext, key []byte) ([]byte, error)
- func EncryptFile(plaintext []byte, key []byte) ([]byte, error)
- func EncryptStream(plaintext, key []byte) ([]byte, error)
- func ExportKey(key []byte) string
- func GenerateKey() ([]byte, error)
- func ImportKey(encoded string) ([]byte, error)
- type StreamHeader
Constants ¶
View Source
const ( // Streaming parameters matching web app StreamMagic = "PHNT" StreamVersion = 1 StreamChunkSize = 64 * 1024 // 64KB chunks StreamNonceSize = 12 StreamTagSize = 16 StreamHeaderSize = 28 // 4 magic + 4 version + 4 chunk_size + 4 total_chunks + 12 base_nonce )
Variables ¶
This section is empty.
Functions ¶
func Decrypt ¶
Decrypt decrypts data encrypted with AES-256-GCM. Expects [12-byte IV][ciphertext + GCM auth tag] format.
func DecryptAuto ¶ added in v0.2.0
DecryptAuto auto-detects format and decrypts (streaming or legacy)
func DecryptFile ¶
DecryptFile decrypts ciphertext and returns the original file contents.
func DecryptStream ¶ added in v0.2.0
DecryptStream decrypts streaming format data
func Encrypt ¶
Encrypt encrypts data with AES-256-GCM. Returns [12-byte IV][ciphertext + GCM auth tag], matching the web app format.
func EncryptFile ¶
EncryptFile reads a file's contents, encrypts it, and returns the ciphertext.
func EncryptStream ¶ added in v0.2.0
EncryptStream encrypts data using streaming AES-256-GCM with STREAM construction
Types ¶
type StreamHeader ¶ added in v0.2.0
type StreamHeader struct {
Magic [4]byte
Version uint32
ChunkSize uint32
TotalChunks uint32
BaseNonce [StreamNonceSize]byte
}
StreamHeader represents the streaming encryption header
Click to show internal directories.
Click to hide internal directories.