Need to create DHPublicKey from y, p, g as BigIntegers
问题 I need a DHPublicKey to encrypt some data. Therefore I have been provided with all the needed parameters as BigIntegers (y, p, g). Unfortunately I don't see a straight way for creating a public key object from these parameters that would fit the DHPublicKey interface. Any idea? 回答1: KeyFactory keyFactory; KeyPairGenerator kpg; DHPublicKey originalDhPubKey, fromSpecsDhPubKey; DHPublicKeySpec dhPubKeySpecs; KeyPair kp; BigInteger p, g, y; // generate a DH key pair kpg = KeyPairGenerator