问题描述
我正在尝试使用密码算法AES / CBC / PKCS7Padding
编写加密代码,HMAC算法HmacSHA256
和密钥导出算法PBKDF2WithHmacSHA256
在android的帮助下。但是它显示: CryptorException:使用PBKDF2WithHmacSHA256无法从密码生成密钥
和
NoSuchAlgorithmException:SecretKeyFactory PBKDF2WithHmacSHA256实现未找到
try {
SecretKeyFactory factory = SecretKeyFactory
.getInstance(KEY_DERIVATION_ALGORITHM);
SecretKey tmp = factory.generateSecret(new PBEKeySpec(password,
salt,getPBKDFIterations(),AES_256_KEY_SIZE * 8));
返回新的SecretKeySpec(tmp.getEncoded(),AES_NAME);
} catch(GeneralSecurityException e){
throw new CryptorException(String.format(
Failed to generate key from password using%s。,
KEY_DERIVATION_ALGORITHM),e);
}
任何帮助将不胜感激。
你可以看一下在项目的一个分支处,,它试图对代码进行几个Android相关的改进。我相信你的问题可能在代码库中得到解决。
据我所知,没有可用的Android提供者提供一个名为 PBKDF2WithHmacSHA256
。非常沮丧!
I am trying to write an encryption code using Cipher Algorithm "AES/CBC/PKCS7Padding"
, HMAC algorithm "HmacSHA256"
and key derivation algorithm "PBKDF2WithHmacSHA256"
with the help of android JNCryptor. But it shows:
CryptorException: Failed to generate key from password using PBKDF2WithHmacSHA256
and
NoSuchAlgorithmException: SecretKeyFactory PBKDF2WithHmacSHA256 implementation not found
try {
SecretKeyFactory factory = SecretKeyFactory
.getInstance(KEY_DERIVATION_ALGORITHM);
SecretKey tmp = factory.generateSecret(new PBEKeySpec(password,
salt, getPBKDFIterations(), AES_256_KEY_SIZE * 8));
return new SecretKeySpec(tmp.getEncoded(), AES_NAME);
} catch (GeneralSecurityException e) {
throw new CryptorException(String.format(
"Failed to generate key from password using %s.",
KEY_DERIVATION_ALGORITHM), e);
}
any help will be appreciated.
Apologies for commenting and not realising you were talking about my software, JNCryptor.
You could take a look at a fork of the project, https://github.com/t0mm13b/AndroJNCryptor, which has attempted to make several Android-related improvements to the code. I believe your problem may be addressed in that code base.
As far as I know, there is no Android provider available that offers an algorithm named PBKDF2WithHmacSHA256
. Quite frustrating!
这篇关于Android加密不工作(PBKDF2WithHmacSHA256加密与AES / CBC / PKCS7Padding)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!