我有加密字符串的功能:
BASE64Decoder decoder = new BASE64Decoder();
BASE64Encoder encoder = new BASE64Encoder();
public String encryptValueWithBlowfish(String data, String secretKey) {
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
try {
SecretKeySpec key = new SecretKeySpec(decoder.decodeBuffer(secretKey), "Blowfish");
Cipher cipher = Cipher.getInstance("Blowfish/CBC/NoPadding", "BC");
String iv = "\0\0\0\0\0\0\0\0";
IvParameterSpec ivs = new IvParameterSpec(iv.getBytes());
cipher.init(Cipher.ENCRYPT_MODE, key, ivs);
MessageDigest sha = MessageDigest.getInstance("SHA-1");
return encoder.encode(sha.digest(cipher.doFinal(decoder.decodeBuffer(data))));
} catch (Exception e) {
lg.info("Failed to encryptValueWithBlowfish: " + e.getMessage());
return "";
}
}
线cipher.init(Cipher.ENCRYPT_MODE, key, ivs);
升异常 "Unsupported keysize or algorithm parameters"
。这段代码在另一台 Linux 机器上可以很好地分叉。两种情况下传递的参数是相同的。我不擅长加密货币。可能有什么问题?