Java 有关EncryptionMode.agile的更多信息

Java 有关EncryptionMode.agile的更多信息,java,encryption,apache-poi,Java,Encryption,Apache Poi,有人能告诉我更多关于EncryptionMode.agile的信息吗? 它使用什么样的算法? 我有一个像这样的pw protect xlsx文件 POIFSFileSystem fs = new POIFSFileSystem(); EncryptionInfo info = new EncryptionInfo(EncryptionMode.agile); // EncryptionInfo info = new EncryptionInfo(EncryptionMo

有人能告诉我更多关于EncryptionMode.agile的信息吗? 它使用什么样的算法? 我有一个像这样的pw protect xlsx文件

POIFSFileSystem fs = new POIFSFileSystem();
        EncryptionInfo info = new EncryptionInfo(EncryptionMode.agile);
     // EncryptionInfo info = new EncryptionInfo(EncryptionMode.agile,  CipherAlgorithm.aes192, HashAlgorithm.sha384, -1, -1, null);

        Encryptor enc = info.getEncryptor();
        enc.confirmPassword(password);

        System.out.println("Read in an existing OOXML file ...");
        OPCPackage opc = OPCPackage.open(new File(filepathname), PackageAccess.READ_WRITE);
编辑: 我正在生成一个xlsx文件,将一些测试数据放入其中并进行加密以获得pw保护

编辑2: 这是EncriptionInfo的内部。看看里面

...
/**
 * Prepares for encryption, using the given Encryption Mode, and
 *  all other parameters as default.
 * @see #EncryptionInfo(EncryptionMode, CipherAlgorithm,   HashAlgorithm,   int, int, ChainingMode)
 */
public EncryptionInfo(EncryptionMode encryptionMode) {
    this(encryptionMode, null, null, -1, -1, null);
}

/**
 * Constructs an EncryptionInfo from scratch
 *
 * @param encryptionMode see {@link EncryptionMode} for values, {@link EncryptionMode#cryptoAPI} is for
 *   internal use only, as it's record based
 * @param cipherAlgorithm
 * @param hashAlgorithm
 * @param keyBits
 * @param blockSize
 * @param chainingMode
 * 
 * @throws EncryptedDocumentException if the given parameters mismatch, e.g. only certain combinations
 *   of keyBits, blockSize are allowed for a given {@link CipherAlgorithm}
 */
public EncryptionInfo(
        EncryptionMode encryptionMode
      , CipherAlgorithm cipherAlgorithm
      , HashAlgorithm hashAlgorithm
      , int keyBits
      , int blockSize
      , ChainingMode chainingMode
  ) {
    versionMajor = encryptionMode.versionMajor;
    versionMinor = encryptionMode.versionMinor;
    encryptionFlags = encryptionMode.encryptionFlags;

    EncryptionInfoBuilder eib;
    try {
        eib = getBuilder(encryptionMode);
    } catch (Exception e) {
        throw new EncryptedDocumentException(e);
    }

    eib.initialize(this, cipherAlgorithm, hashAlgorithm, keyBits, blockSize, chainingMode);

    header = eib.getHeader();
    verifier = eib.getVerifier();
    decryptor = eib.getDecryptor();
    encryptor = eib.getEncryptor();
}...
这是AgileEncyptionInfoBuilder的内部

     @Override
public void initialize(EncryptionInfo ei, CipherAlgorithm   cipherAlgorithm, HashAlgorithm hashAlgorithm, int keyBits, int blockSize,   ChainingMode chainingMode) {
    this.info = ei;

    if (cipherAlgorithm == null) {
        cipherAlgorithm = CipherAlgorithm.aes128;
    }
    if (cipherAlgorithm == CipherAlgorithm.rc4) {
        throw new EncryptedDocumentException("RC4 must not be used with agile encryption.");
    }
    if (hashAlgorithm == null) {
        hashAlgorithm = HashAlgorithm.sha1;
    }
    if (chainingMode == null) {
        chainingMode = ChainingMode.cbc;
    }...
您可能还需要在windows上安装JCE

以下是一个很好的指南: (只需覆盖lib\security、all.on jre和jdk位置中的.jar)

或者使用弹跳城堡
不要使用“VelvetSweatshop”作为你的.xlsx密码:D

你读过这页了吗。。。它包含到官方MS-OFF加密文档的链接。除此之外,我还为接口提供了非常好的枚举。。。使用它们怎么样?。。。而且似乎您想要删除现有的.xlsx。您复制和粘贴的代码用于加密文档不太好。5k页ECMA-376。。。但是查看org.apache.poi.poifs.crypt.EncryptionInfo内部情况要好得多;)@如果你自己研究过,那么你可以自己发布答案。它可能对未来的读者有用。