我正在尝试使用addProvider
方法,即使它已导入import java.security.Security;
package com.example.fingerprient2;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.Signature;
import java.security.Security;
import java.security.interfaces.ECPublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.X509EncodedKeySpec;
import java.util.Arrays;
import java.security.Security;
import org.bouncycastle.jcajce.BCFKSLoadStoreParameter;
import org.bouncycastle.jce.ECNamedCurveTable;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.jce.spec.ECParameterSpec;
import android.security.keystore.KeyProperties;
import javax.crypto.KeyGenerator;
public class EnCryptor {
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
KeyPairGenerator kpg = KeyPairGenerator.getInstance(
KeyProperties.KEY_ALGORITHM_EC, "AndroidKeyStore");
KeyGenerator keyGenerator =KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_EC ,"AndroidKeyStore");
}
有什么帮助知道为什么为什么没有出现addProvider?
答案 0 :(得分:0)
因为您不在可以调用方法的范围内。需要从函数或初始化程序中调用它:
public class Encryptor {
public void initialize() {
Security.addProvider(new BouncyCastleProvider());
}
}