Code example for PKCS8EncodedKeySpec

Methods: getEncoded

0
     * Assertion: returns encoded key 
     */ 
    public final void testGetEncoded() { 
        byte[] encodedKey = new byte[] {(byte)1,(byte)2,(byte)3,(byte)4};
         
        PKCS8EncodedKeySpec meks = new PKCS8EncodedKeySpec(encodedKey);
         
        byte[] ek = meks.getEncoded();
         
        assertTrue(Arrays.equals(encodedKey, ek));
    } 
     
    /** 
     * Test for <code>getFormat()</code> method 
     * Assertion: returns format name (always "PKCS#8") 
     */ 
    public final void testGetFormat() { 
        byte[] encodedKey = new byte[] {(byte)1,(byte)2,(byte)3,(byte)4};
         
        PKCS8EncodedKeySpec meks = new PKCS8EncodedKeySpec(encodedKey);