public static SecretKey generateKey ( final byte [ ] key ) { return new SecretKey ( ) { private byte [ ] k ; { if ( key . length == 16 ) { k = key ; } else { k = new byte [ 16 ] ; System . arraycopy ( key , 0 , k , 0 , key . length < 16 ? key . length : 16 ) ; } } @ Override public String getAlgorithm ( ) { return "AES" ; } @ Override public String getFormat ( ) { return "RAW" ; } @ Override public byte [ ] getEncoded ( ) { return k ; } } ; }
16 bytes max 128 - bit encription