我的代码遇到了这个问题。
public byte[] encryptString(String unencryptedData, String encryptionKey) throws Exception {
Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding", "SunJCE");
SecretKeySpec key = new SecretKeySpec(encryptionKey.getBytes("UTF-8"), "AES"); //256-AES, 512-AES
cipher.init(Cipher.ENCRYPT_MODE, key,new IvParameterSpec(encryptionKey.getBytes("UTF-8")));
return cipher.doFinal(unencryptedData.getBytes("UTF-8"));
}
答案 0 :(得分:0)
您可以使用此代码查看哪些提供商和算法组合可用:
for (Provider p : Security.getProviders()) {
Log.e(TAG, "Service Name: " + p.getName()));
for (Provider.Service s : p.getServices()) {
Log.e(TAG, " Algorithm: " + s.getAlgorithm()));
}
}