string trans_e(string a,string c) {
int f = 0,h = 0,last = 0;
int b[256];
string result = "";
while (h < 256) {
f = (f + b[h] + Convert.ToInt32(a[h % a.Length])) % 256
last = b[h];
b[h] = b[f];
b[f] = last;
h += 1;
}
int q = 0,f = 0,h = 0;
while (q < c.Length ) {
h = (h + 1) % 256;
f = (f + b[h]) % 256;
last = b[h];
b[h] = b[f];
b[f] = last;
int outint = 0;
if ( int.TryParse(c[q].ToString(),out outint) ) {
result += Convert.ToChar(c[q] ^ b[(b[h] + b[f]) % 256]);
} else {
result += Convert.ToChar(Conver.ToInt32(c[q]) ^ b[(b[h] + b[f]) % 256]);
q += 1;
}
return result;
}
string[] generate_ep(string vid, string ep) {
string result[3];
string f_code_1 = "becaf9be";
string f_code_2 = "bf7e5f01";
string e_code = trans_e(f_code_1, Convert.FromBase64String(ep));
string sid = e_code.Split("_")[0];
string token = e_code.Split("_")[1];
string new_ep = trans_e(f_code_2, sid + "_" + vid + "_" + token))
result[0] = Convert.ToBase64String(Encoding.GetEncoding("lanin").GetString(new_ep));
result[1] = sid;
result[2] = token;
return result;
}