private static byte[] convertToByteArray(CharSequence charSequence){
  checkNotNull(charSequence);
  byte[] byteArray=new byte[charSequence.length() << 1];
  for (int i=0; i < charSequence.length(); i++) {
    int bytePosition=i << 1;
    byteArray[bytePosition]=(byte)((charSequence.charAt(i) & 0xFF00) >> 8);
    byteArray[bytePosition + 1]=(byte)(charSequence.charAt(i) & 0x00FF);
  }
  return byteArray;
}

private static byte [ ] convertToByteArray ( CharSequence charSequence ) { checkNotNull ( charSequence ) ; byte [ ] byteArray = new byte [ charSequence . length ( ) << 1 ] ; for ( int i = 0 ; i < charSequence . length ( ) ; i ++ ) { int bytePosition = i << 1 ; byteArray [ bytePosition ] = ( byte ) ( ( charSequence . charAt ( i ) & 0xFF00 ) > > 8 ) ; byteArray [ bytePosition + 1 ] = ( byte ) ( charSequence . charAt ( i ) & 0x00FF ) ; } return byteArray ; }
convert a charsequence ( which are utf16 ) into a byte array . note : a string . getbytes ( ) is not used to avoid creating a string of the password in the jvm .
