问题描述
我已经在Web应用程序的服务器代码中一次又一次地使用此代码或类似的代码,但是现在我试图制作一个命令行实用程序来与维护后端一起使用.
I have used this code or something similar time and again within the server code on my web apps, but now I am trying to make a command line utility to work with the maintenance backend.
继续获取EncryptionOperationNotPossibleException
,但看不到我在代码中做错了什么.为了测试代码段,我使用了真实的加密字符串来确保它不是测试输入.
Keep on getting a EncryptionOperationNotPossibleException
, but can't see what I'm doing wrong in the code. To test the snippet I've used a real encrypted string to make sure it's not the test input.
外面的人看到异常代码从哪里来吗?
Anybody out there see where in the code this exception would come from?
import org.jasypt.exceptions.EncryptionOperationNotPossibleException;
import org.jasypt.util.text.BasicTextEncryptor;
public class decipher {
/**
* @param args
*/
public static void main(String[] args) {
if (args[0] != null) {
String encstr = args[0];
String decstr = "";
if (encstr != null && !encstr.equals("")) {
try {
BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
textEncryptor.setPassword("1234566789");
decstr = textEncryptor.decrypt(encstr);
System.out.println(decstr);
} catch (EncryptionOperationNotPossibleException e) {
System.out.println(e.toString());
}
} else {
System.out.println("Passed empty string... not decrypted.");
}
} else {
System.out.println("This program requires and encrypted text input.");
}
}
}
推荐答案
已修复!原来我使用的输入字符串不是有效的加密字符串!首先使用加密运行脚本,复制并粘贴字符串,然后针对该字符串运行解密...
Fixed!! Turns out the input string that I was using was not a valid encrypted string in the first place!! First run your script with encrypt, copy and past a string, then run decrypt against that string...
这篇关于拒绝...简单代码,但是... org.jasypt.exceptions.EncryptionOperationNotPossibleException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!