0
다음 코드를 사용하여 키를 만들었지 만 KeyGeneration.getPublicKey()
을 사용하려고하면 null
을 반환합니다. 아래공용 및 개인 키 만들기
public KeyGeneration() throws Exception,(more but cleared to make easier to read)
{
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
kpg.initialize(1024);
KeyPair kp = kpg.genKeyPair();
PublicKey publicKey = kp.getPublic();
PrivateKey privateKey = kp.getPrivate();
}
public static PublicKey getPublicKey() { return publicKey; }
오류 메시지 : 당신이 전체 코드를보고 싶은 경우
java.security.InvalidKeyException: No installed provider supports this key: (null)
at javax.crypto.Cipher.chooseProvider(Cipher.java:878)
at javax.crypto.Cipher.init(Cipher.java:1213)
at javax.crypto.Cipher.init(Cipher.java:1153)
at RSAHashEncryption.RSAHashCipher(RSAHashEncryption.java:41)
at RSAHashEncryption.exportEHash(RSAHashEncryption.java:21)
at Main.main(Main.java:28)
, 내가 여기에 게시 할 수 있습니다.
PublicKey publicKey = kp.getPublic();
지역 변수에 기록하지만,이된다 :
public static PublicKey getPublicKey() { return publicKey; }
사용중인 자바 버전은 무엇입니까? –
전체 코드가 필요하지 않습니다. [SSCCE] (http://www.sscce.org) =) –