PeachScriptExport.kt

1.4 KB · raw

1package com.peachpasswords.ui.vault23import com.peachpasswords.vault.PeachPayloadCodec4import com.peachpasswords.vault.PeachScript5import com.peachpasswords.vault.VaultEntry6import com.peachpasswords.vault.VaultSettings78/**9 * PeachScript export (MF-2) — writes the browser's PCHS binary payload10 * (Argon2id + AES-256-GCM, zstd sections, BLAKE3 checksum, size-bucket padding,11 * string-table entry packing) re-encoded into Private-Use-Area text. The output12 * is importable by the browser extension and carries the full entry field set.13 *14 * The heavy lifting lives in [PeachPayloadCodec] (binary) and [PeachScript]15 * (PUA codec); this object is just the export entry point the UI calls.16 */17object PeachScriptExport {1819    /**20     * Encrypted PeachScript export of [entries], protected by [backupPassword].21     * PeachScript is always encrypted (the browser format has no plaintext mode).22     */23    fun buildEncrypted(24        entries: List<VaultEntry>,25        backupPassword: String,26        settings: VaultSettings = VaultSettings(),27        licenseKey: String? = null,28        licenseActivatedAt: Long? = null,29    ): String =30        PeachScript.encode(31            PeachPayloadCodec.buildPayload(32                entries = entries,33                passphrase = backupPassword,34                settings = settings,35                licenseKey = licenseKey,36                licenseActivatedAt = licenseActivatedAt,37            ),38        )39}