[C#] 纯文本查看 复制代码
private void button1_Click(object sender, EventArgs e)
{
ScriptControlClass js = new ScriptControlClass();
js.Language = "JScript";
StringBuilder str = new StringBuilder();
str.Append("function getGtk(str) {");
str.Append("var hash = 5381;");
str.Append("for (var i = 0,");
str.Append("len = str.length; i < len; ++i) {");
str.Append("hash += (hash << 5) + str.charAt(i).charCodeAt();");
str.Append("}");
str.Append("return hash & 0x7fffffff;}");
js.AddCode(str.ToString());
string result = null;
result = js.Eval("getGtk('123456')").ToString();
MessageBox.Show(result);
}