/// <summary>Use a special char to padd up to AES block. /// TODO upgrade the java side /// Reference: /// \u2020, ? , a char not easy to be keyed in /// https://www.unicode.org/charts/PDF/Unicode-3.2/U32-2000.pdf /// \u0000, Nil /// https://www.unicode.org/charts/PDF/U0000.pdf /// </summary> /// <param name="s"></param> /// <returns> 16 / 32 byte string /// </returns> /// <exception cref="Exception"></exception> private static byte[] pad16_32(string s) { int l = Encoding.Unicode.GetByteCount(s); if (l <= 16) { l = 16; } else if (l <= 32) { l = 32; } else { throw new Exception("Not supported block length(16B/32B): " + s); } byte[] buf = new byte[l]; LangExt.Fill <byte>(buf, 0); Encoding.Unicode.GetBytes(s, 0, s.Length, buf, 0); return(buf); }