Code example for X509EncodedKeySpec

Methods: getEncoded

0
        level = TestLevel.PARTIAL_COMPLETE, 
        notes = "", 
        method = "getEncoded", 
        args = {} 
    ) 
    public final void testIsStatePreserved1() { 
        // Reference array 
        byte[] encodedKey = new byte[] {(byte)1,(byte)2,(byte)3,(byte)4};
        // Reference array's copy will be used for test 
        byte[] encodedKeyCopy = encodedKey.clone();
         
        X509EncodedKeySpec meks = new X509EncodedKeySpec(encodedKeyCopy);
         
        // Modify initial array's value 
        encodedKeyCopy[3] = (byte)5;
         
        // Get encoded key 
        byte[] ek = meks.getEncoded();
         
        // Check  using reference array that 
        // byte value has not been changed