jasypt无效的文本解密

时间:2016-10-17 07:14:57

标签: java encryption jasypt

我遇到一个问题,我在使用jasypt解密一些文本时遇到异常。我已经安装Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files并且加密工作正常。

这是我的示例代码

PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
         int number_of_cores = Runtime.getRuntime().availableProcessors();
         encryptor.setPoolSize(number_of_cores);
         encryptor.setAlgorithm("PBEWITHHMACSHA512ANDAES_256");
         encryptor.setPassword("stackoverflow");
         String plaintext = "This is a test";
         String encryptedtext = encryptor.encrypt(plaintext);
         String decryptedtext = encryptor.decrypt(encryptedtext);
         System.out.println(plaintext);
         System.out.println(encryptedtext);
         System.out.println(decryptedtext); 

错误:

Exception in thread "main" org.jasypt.exceptions.EncryptionOperationNotPossibleException
    at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.decrypt(StandardPBEByteEncryptor.java:1055)
    at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:725)
    at org.jasypt.encryption.pbe.PooledPBEStringEncryptor.decrypt(PooledPBEStringEncryptor.java:498)

0 个答案:

没有答案