I need to protect a generated word file. user should only be able to edit it if they know the password to unlock it. I tried it with the following code:
- Code: Select all
DocumentSettingsPart dsp = doc.getDocumentSettingsPart();
ObjectFactory factory = new ObjectFactory();
CTDocProtect protection = factory.createCTDocProtect();
protection.setEdit(STDocProtect.COMMENTS);
protection.setEnforcement(true);
protection.setCryptProviderType(STCryptProv.RSA_FULL);
protection.setCryptAlgorithmClass(STAlgClass.HASH);
protection.setCryptAlgorithmType(STAlgType.TYPE_ANY);
protection.setCryptAlgorithmSid(BigInteger.valueOf(4));
protection.setCryptSpinCount(BigInteger.valueOf(100000));
protection.setHash(???);
protection.setSalt(???);
dsp.getJaxbElement().setDocumentProtection(protection);
how can I evaluate the hash and the salt value for a given password and document?
greetings, nick