Security “Crypto” provider deprecated in Android N

For 8.0 and above you can refere here

For below 8.0 version you can go through following code.

You can use this provider replacing “Crypto” for SecureRandom, its working for me fine:


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

instead of,

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

and your CryptoProvider class like as below,

 * 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 ImplementedIn", "Software");

Leave a Comment