Итак, я ищу простой ответ, как создать хэш и соль для защиты слова с помощью библиотеки 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);
}
Я действительно попробовать все, даже перевести C# код из http://social.msdn.microsoft.com/Forums/vstudio/en-US/63588f50-354f-43ba-b080-e0e6c51a0fb5/hash-and-saltdocumentprotection. Я хочу полностью автоматизировать настройку пароля для файлов docx.
Вы ищете для сравнения файлов? У меня такая же проблема! http://stackoverflow.com/questions/13411678/docx4j-giving-wrong-result –
Так что случилось, когда вы перевели код C#? Может быть, вы должны добавить этот код к своим вопросам. – JasonPlutext