private static byte [ ] convertKeyToByteArray ( String key ) { byte [ ] result = new byte [ key . length ( ) ] ; for ( int i = 0 ; i < result . length ; i ++ ) { char thisChar = key . charAt ( i ) ; result [ i ] = ( byte ) ( thisChar >>> 8 & 0xFF ^ thisChar & 0xFF ) ; } return result ; }
Convert the key to a byte array by compressing the 16 - bit characters to bytes . This XOR compression insures that the top 8 bits are still significant so a key of \ u0020 yields a different cipher than a key of \ u0120 .