Security "Crypto" provider is deprecated in Android N

A user runs my application in Android N, he got crash. I know that Google has deprecated the Crypto provider in Android N, but what would be the best way to migrate old encrypted data.

+3
android
Aug 23 '16 at 9:14
source share
1 answer

For 8.0 and above, you can refer here

For versions below 8.0, you can go through the following code.

You can use this provider by replacing "Crypto" with SecureRandom, it works great for me:

Using,

SecureRandom sr = SecureRandom.getInstance("SHA1PRNG", new CryptoProvider()); 

instead,

 SecureRandom sr = SecureRandom.getInstance("SHA1PRNG","Crypto"); 

and your CryptoProvider class as shown below

 import java.security.Provider; /** * Implementation of Provider for SecureRandom. The implementation supports the * "SHA1PRNG" algorithm described in JavaTM Cryptography Architecture, API * Specification & Reference */ public final class CryptoProvider extends Provider { /** * Creates a Provider and puts parameters */ public CryptoProvider() { super("Crypto", 1.0, "HARMONY (SHA1 digest; SecureRandom; SHA1withDSA signature)"); put("SecureRandom.SHA1PRNG", "org.apache.harmony.security.provider.crypto.SHA1PRNG_SecureRandomImpl"); put("SecureRandom.SHA1PRNG ImplementedIn", "Software"); } } 
+21
Feb 20 '17 at 6:26
source share



All Articles