@act262
2017-04-25T06:07:51.000000Z
字数 1605
阅读 1301
Android
Android App 中targetSdkVersion的作用
加密算法的变动:
SecureRandom sr = SecureRandom.getInstance(SHA1, CRYPTO);
public static SecureRandom getInstance(String algorithm, String provider)
throws NoSuchAlgorithmException, NoSuchProviderException {
try {
Instance instance = GetInstance.getInstance("SecureRandom",
SecureRandomSpi.class, algorithm, provider);
return new SecureRandom((SecureRandomSpi) instance.impl,
instance.provider, algorithm);
} catch (NoSuchProviderException nspe) {
if ("Crypto".equals(provider)) {
System.logE(" ********** PLEASE READ ************ ");
System.logE(" * ");
System.logE(" * New versions of the Android SDK no longer support the Crypto provider.");
System.logE(" * If your app was relying on setSeed() to derive keys from strings, you");
System.logE(" * should switch to using SecretKeySpec to load raw key bytes directly OR");
System.logE(" * use a real key derivation function (KDF). See advice here : ");
System.logE(" * http://android-developers.blogspot.com/2016/06/security-crypto-provider-deprecated-in.html ");
System.logE(" *********************************** ");
// Target SDK <= 23 时使用旧版本的功能
if (VMRuntime.getRuntime().getTargetSdkVersion()
<= sdkTargetForCryptoProviderWorkaround) {
System.logE(" Returning an instance of SecureRandom from the Crypto provider");
System.logE(" as a temporary measure so that the apps targeting earlier SDKs");
System.logE(" keep working. Please do not rely on the presence of the Crypto");
System.logE(" provider in the codebase, as our plan is to delete it");
System.logE(" completely in the future.");
return getInstanceFromCryptoProvider(algorithm);
}
}
throw nspe;
}
}
mButtonGravity = a.getInteger(R.styleable.Toolbar_buttonGravity, Gravity.TOP);