Android encryption not working (PBKDF2WithHmacSHA256 encryption with AES/CBC/PKCS7Padding)

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.

Answers


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!


Need Your Help

Padding different in Firefox

css firefox cross-browser

In all the browsers I've tested, my button looks like this:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.