Code example for DSAPublicKey

Methods: getParamsgetY

0
               Key key = fact.generatePublic(new X509EncodedKeySpec(encoded));
 
               assertTrue("public key encodings were different", 
                           isEqual(key, keys.getPublic()));
 
               // check private key encoding 
               encoded = keys.getPrivate().getEncoded();
               key = fact.generatePrivate(new PKCS8EncodedKeySpec(encoded));
 
               assertTrue("private key encodings were different",
                           isEqual(key, keys.getPrivate()));
    } 
 
    private boolean isEqual(Key key1, Key key2) {
        if (key1 instanceof DSAPublicKey && key2 instanceof DSAPublicKey) {
            DSAPublicKey dsa1 = ((DSAPublicKey) key1);
            DSAPublicKey dsa2 = ((DSAPublicKey) key2);
            return dsa1.getY().equals(dsa2.getY())
                    && dsa1.getParams().getG().equals(dsa2.getParams().getG())
                    && dsa1.getParams().getP().equals(dsa2.getParams().getP())
Contextual code suggestions in your IDE  Get Codota for Java