tonhowtf/omniget · error

não cifrei

Error message

não cifrei: {}

What it means

Crypto failure in password_one: doc.encrypt with the AES-128 StdCF state returned an error — malformed document objects or unsupported prior encryption — so the PDF could not be secured and the item fails.

Solutions

  1. Read the wrapped inner lopdf error for the root cause
  2. Ensure mode="remove" was used first to strip any pre-existing Encrypt dictionary before re-encrypting
  3. Update lopdf to the latest version for encryption fixes
  4. Save to a fresh copy of the document and retry

Example fix

// before
doc.encrypt(&state).map_err(|e| anyhow!("não cifrei: {}", e))?;
// after
doc.trailer.remove(b"Encrypt"); // clear stale encryption dict first
doc.encrypt(&state).map_err(|e| anyhow!("falha ao cifrar PDF: {}", e))?;
Defensive patterns

Strategy: try-catch

Validate before calling

// remove stale encryption before re-encrypting
doc.trailer.remove(b"Encrypt");

Try / catch

doc.encrypt(&state)
    .map_err(|e| anyhow!("falha ao aplicar cifragem: {}", e))?;

Prevention

When it happens

Trigger: doc.encrypt(&state) returns Err after EncryptionState was built successfully — typically an lopdf-internal problem computing the encryption dictionary/keys for this document.

Common situations: Unusual PDF structures (existing Encrypt remnants in the trailer) conflicting with the new state; lopdf version bugs; document loaded in a state where encryption cannot be applied.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/cb746002dad93e45. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/pdf_write.rs:171

                    Object::string_literal(id),
                ]),
            );
        }
        let filter: Arc<dyn CryptFilter> = Arc::new(Aes128CryptFilter);
        let version = EncryptionVersion::V4 {
            document: &doc,
            encrypt_metadata: true,
            crypt_filters: BTreeMap::from([(b"StdCF".to_vec(), filter)]),
            stream_filter: b"StdCF".to_vec(),
            string_filter: b"StdCF".to_vec(),
            owner_password: owner,
            user_password: &opts.user_password,
            permissions: permissions_of(opts),
        };
        let state =
            EncryptionState::try_from(version).map_err(|e| anyhow!("não montei a cifra: {}", e))?;
        doc.encrypt(&state)
            .map_err(|e| anyhow!("não cifrei: {}", e))?;
        note = if opts.user_password.is_empty() {
            "permissões travadas (abre sem senha)".into()
        } else {
            "AES-128, senha para abrir".into()
        };
    }
    let out = out_path(
        input,
        &opts.output_dir,
        &opts.suffix,
        if opts.mode == "remove" {
            "-sem-senha"
        } else {
            "-protegido"
        },
    )?;
    doc.save(&out).map_err(|e| anyhow!("não gravei: {}", e))?;
    Ok(WriteItem {

View on GitHub (pinned to 8600b91f42)