几年前我使用了iRead和JasPB报告,我不记得这些细节,但我记得你可以用某种方式来评估Java代码。使用该功能,您可以用几行计算MD5:
String encryptionAlgorithm = "MD5";
String valueToEncrypt = "StackOverflow";
MessageDigest msgDgst = MessageDigest.getInstance(encryptionAlgorithm);
msgDgst.update(valueToEncrypt.getBytes(), 0, valueToEncrypt.length());
String md5 = new BigInteger(1, msgDgst.digest()).toString(16) ;
System.out.println(md5);
需要导入java.math.bigineger、java.security.messagedigest和java.security.nosuchalgorithmexception;
计算sha1散列几乎是相同的:
String encryptionAlgorithm = "SHA-1";
String valueToEncrypt = "StackOverflow";
MessageDigest msgDgst = MessageDigest.getInstance(encryptionAlgorithm);
byte[] sha1hash = new byte[40];
msgDgst.update(valueToEncrypt.getBytes(), 0, valueToEncrypt.length());
sha1hash = md.digest();
查看此日志,了解如何创建可在报表运行时评估的变量
http://www.eakes.org/77/java-injection-in-jasper-reports/