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 файлове.


person Rafal Mikolajczuk    schedule 24.06.2013    source източник
comment
Търсите ли сравнение на файлове? Имам същия проблем! stackoverflow.com/questions/13411678/docx4j-giving-wrong-result   -  person Abbas Hashmi    schedule 25.06.2013
comment
И така, какво се обърка, когато преведохте C# кода? Може би трябва да добавите този код към вашите въпроси.   -  person JasonPlutext    schedule 27.06.2013


Отговори (1)