Cipher not initialized

后端 未结 1 1560
慢半拍i
慢半拍i 2021-02-11 11:36

I decided to use generic object pooling to reuse cipher object by following A Generic and Concurrent Object Pool . The different is that the article using Connection

1条回答
  •  死守一世寂寞
    2021-02-11 11:58

    I think you're on the correct path. I think you need to initialize the Cipher in the createNew() method:

    @Override
    public Cipher createNew() {
        try {
            System.out.print("Instances : " + instance);
            Cipther result = Cipher.getInstance(this.instance);
            result.init(...); // use the right init params, e.g. opmode, crypto key
            return result;
        } catch (NoSuchAlgorithmException | NoSuchPaddingException se) {
            throw new IllegalArgumentException(
                    "Unable to create new cipher", se);
        }
    }
    

    0 讨论(0)
提交回复
热议问题