The security encryption provider is deprecated in Android n
•
Android
I know Google has abandoned the crypto provider in Android n, but what is the best way to migrate old encrypted data
resolvent:
For 8.0 and above, you can refer to here
For versions below 8.0, you can view the following code
You can use this provider to replace securerandom's encryption, which is useful to me:
use,
SecureRandom sr = SecureRandom.getInstance("SHA1PRNG", new CryptoProvider());
Instead,
SecureRandom sr = SecureRandom.getInstance("SHA1PRNG","Crypto");
And your cryptoprovider class is as follows,
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");
}
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码