{"record":{"id":"13ca4ad3af1dd301","repo":"tonhowtf/omniget","slug":"n-o-montei-a-cifra","errorCode":null,"errorMessage":"não montei a cifra: {}","messagePattern":"não montei a cifra: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/pdf_write.rs","lineNumber":169,"sourceCode":"                Object::Array(vec![\n                    Object::string_literal(id.clone()),\n                    Object::string_literal(id),\n                ]),\n            );\n        }\n        let filter: Arc<dyn CryptFilter> = Arc::new(Aes128CryptFilter);\n        let version = EncryptionVersion::V4 {\n            document: &doc,\n            encrypt_metadata: true,\n            crypt_filters: BTreeMap::from([(b\"StdCF\".to_vec(), filter)]),\n            stream_filter: b\"StdCF\".to_vec(),\n            string_filter: b\"StdCF\".to_vec(),\n            owner_password: owner,\n            user_password: &opts.user_password,\n            permissions: permissions_of(opts),\n        };\n        let state =\n            EncryptionState::try_from(version).map_err(|e| anyhow!(\"não montei a cifra: {}\", e))?;\n        doc.encrypt(&state)\n            .map_err(|e| anyhow!(\"não cifrei: {}\", e))?;\n        note = if opts.user_password.is_empty() {\n            \"permissões travadas (abre sem senha)\".into()\n        } else {\n            \"AES-128, senha para abrir\".into()\n        };\n    }\n    let out = out_path(\n        input,\n        &opts.output_dir,\n        &opts.suffix,\n        if opts.mode == \"remove\" {\n            \"-sem-senha\"\n        } else {\n            \"-protegido\"\n        },\n    )?;","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/pdf_write.rs#L151-L187","documentation":"After picking the encryption version, password_one converts it into an lopdf EncryptionState via EncryptionState::try_from(version). If that conversion fails (unsupported combination of cipher version, filters, or passwords), the error is wrapped as 'não montei a cifra: {}'.","triggerScenarios":"EncryptionState::try_from returns Err — e.g. the chosen cipher version/filter combination is not supported by the installed lopdf version, or password bytes exceed what the cipher revision allows.","commonSituations":"Upgrading/downgrading lopdf changes which EncryptionState variants are constructible; custom permissions or filter names rejected; extremely long passwords truncated/invalid for RC4/AES-40 revisions.","solutions":["Inspect the wrapped inner error message for the exact lopdf rejection reason","Use the default cipher version and \"StdCF\" string filter as in the surrounding code instead of a custom EncryptionDictionary version","Pin a lopdf version whose EncryptionState::try_from supports your configuration","Shorten passwords if the target revision limits them"],"exampleFix":"// before\nlet state = EncryptionState::try_from(version).map_err(|e| anyhow!(\"não montei a cifra: {}\", e))?;\n// after\nlet state = EncryptionState::try_from(version)\n    .map_err(|e| anyhow!(\"combinação de cifra não suportada ({:?}): {}\", version, e))?;","handlingStrategy":"try-catch","validationCode":"// stick to the supported combo: default version + StdCF filter + short passwords\nassert!(!owner.is_empty());\nassert!(owner.len() <= 32, \"senha muito longa para AES-128\");","typeGuard":null,"tryCatchPattern":"let state = EncryptionState::try_from(version)\n    .map_err(|e| anyhow!(\"cifra não suportada nesta versão do lopdf: {}\", e))?;","preventionTips":["Use the default encryption version and StdCF filter","Pin and test against the lopdf version in CI","Keep passwords within the cipher revision's length limits"],"tags":["pdf","encryption","lopdf","config"],"backgroundTag":"invalid-config-value","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}