Skip to main content

encrypt_secrets

Function encrypt_secrets 

Source
pub fn encrypt_secrets(pubkey_hex: &str, plaintext: &str) -> Result<String>
Expand description

Encrypt plaintext with ChaCha20-Poly1305 using hex-encoded pubkey as symmetric key.

Matches dashboard’s JS implementation exactly:

  1. Parse hex pubkey → 32-byte key
  2. Generate 12-byte random nonce
  3. Encrypt plaintext
  4. Result: base64([12-byte nonce] + [ciphertext + 16-byte auth tag])