java - Docx4j 哈希和盐

标签 java docx4j

所以我寻找简单的答案,如何使用 docx4j 库为字保护选项生成哈希和盐?

我得到了这个方法:

public static void setUpReadOnlyDocumentWithPassword(DocumentSettingsPart documentSettingsPart, String password) {
    final CTSettings settings = Context.getWmlObjectFactory().createCTSettings();
    final CTDocProtect protection = Context.getWmlObjectFactory().createCTDocProtect();
    protection.setEdit(STDocProtect.READ_ONLY);
    protection.setFormatting(true);
    protection.setEnforcement(true);
    protection.setCryptProviderType(STCryptProv.RSA_FULL);
    protection.setCryptAlgorithmClass(STAlgClass.HASH);
    protection.setCryptAlgorithmType(STAlgType.TYPE_ANY);
    protection.setCryptAlgorithmSid(new BigInteger("4"));
    protection.setCryptSpinCount(new BigInteger("100000"));
    protection.setHash(?????);
    protection.setSalt(?????);
    settings.setDocumentProtection(protection);
    documentSettingsPart.setJaxbElement(settings);
}

我真的尝试了一切,甚至翻译 http://social.msdn.microsoft.com/Forums/vstudio/en-US/63588f50-354f-43ba-b080-e0e6c51a0fb5/hash-and-saltdocumentprotection 中的 C# 代码。 我想全自动设置 docx 文件的密码。

最佳答案

关于java - Docx4j 哈希和盐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17272102/

相关文章:

java - 使用java库解析VML Path属性值

java - 在 Java 程序中跟踪时间

java - 如何使用 docx4j 将 docx 导出为 png?

java - 如何使用java api合并两个具有图表和表格的pptx文件?

java - 如何将 Docx4j 中的 HTML <h3> </h3> 转换为 MS 文档 Heading3?

java - 转换为 HTML 时导入外部 CSS 文件

java - 嵌套循环打印一个数字,旁边有相同数量的星号

java - 为什么在 Java 中可以在没有竞争条件的情况下并发更新原子变量?

java - Jersey servlet 类是根据每个请求构建的

java - 如何在 Intellij 中将一个项目从一台计算机传输到另一台计算机?