I am trying to create an Android application that uses encryption to store user information, and I cannot understand what I am doing wrong. I am trying to create an instance of SecretKeyFactory using the "PBKDF2WithHmacSHA1" algorithm, but the application continues to throw exceptions at this point in the program (it does not matter whether it is in the emulator or on real hardware).
the code:
SecretKeyFactory secretFactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
An exception:
java.security.NoSuchAlgorithmException: SecretKeyFactory PBKDF2WithHmacSHA1 implementation not found ...
Here's the strange thing ... if I take this code and compile it as a regular Java application, it works ... no exceptions arise, and I can create encrypted files (and decrypt them) without errors.
I also tried to introduce other algorithms (e.g. AES, PBEWithHmacSHA1AndDESede, PBEWithMD5AndDES, etc.), and they all produce the same error / exception on this line in the code (when compiling for Android).
I have the latest version of Java (JDK 1.6.0.18) installed, all updates applied to Eclipse and plugins, and the latest version of the Android SDK. I also use the 64-bit version of Windows 7.
Please help, I did not find an answer to this after two days of searching the Internet. Thanks.
java android encryption
Ryanm
source share