public static string Escape(string raw) { if (IsEmpty(raw)) { return(""); } int length = raw.Length(); int i = 0; StrBuilder sbr = new StrBuilder(raw.Length() / 2); while (i < length) { char c = raw.CharAt(i++); if (CharUtils.IsLetterOrDigit(c) || CharUtils.IsEscapeExempt(c)) { sbr.Append(c); } else { int i1 = raw.CharAt(i - 1); string escape = CharUtils.ToHex(i1); sbr.Append('%'); if (escape.Length > 2) { sbr.Append('u'); } sbr.Append(escape.ToUpper()); } } return(sbr.ToString()); }
public string EncryptBytes(sbyte[] buffer) { Md5Init(); Md5Update(buffer, buffer.Length); Md5Final(); StrBuilder buf = new StrBuilder(); for (int i = 0; i < 16; i++) { buf.Append(CharUtils.ToHex(digest[i])); } return(buf.ToString()); }