Code example for KeyFactory

Methods: generatePrivategetKeySpec, translateKey

0
                  public String getAlgorithm() { return "DSA"; }
                  public byte[] getEncoded()   { return enc2; }
                  public String getFormat()    { return "PKCS8"; }
              }; 
 
        PKCS8EncodedKeySpec ks = kf.getKeySpec(prKey, PKCS8EncodedKeySpec.class);
 
        prKey = (DSAPrivateKey) kf.generatePrivate((KeySpec)ks);
        prKey = (DSAPrivateKey) kf.translateKey( (Key)prKey );
 
        String alg = prKey.getAlgorithm();
        assertNotNull(alg);
        assertFalse("PKCS8".equals(alg));
    } 
 
 
    public static Test suite() {
        return new TestSuite(DSAKeyFactoryImplTest.class);
    } 
 
Stop searching for code, let great code find you!  Add Codota to your java IDE