public class BaiduHelper
{
static int F = 0;
static string I = "", J = "";
static string O = "";
static string E = "";
static int[] K = new int[1000];
static int[] H = new int[1000];
static int M = 0;
/// <summary>
/// GetBaiduMp3Url
/// </summary>
/// <param name="str"></param>
/// <param name="key"></param>
/// <returns></returns>
public static string GetBaiduMp3Url(String str, int key)
{
F = key;
I = str;
J = str;
N(0, 9, 48);
N(10, 35, 55);
N(36, 61, 61);
M = F % 26;
M = (M > -1) ? M : 1;
O = A(I);
E = (I == J) ? O : A(J);
return E;
}
public static void N(int S, int P, int Q)
{
for (int R = S; R <= P; R++)
{
K[R] = R + Q;
H[R + Q] = R;
}
}
public static string A(string Q)
{
int P = Q.Length;
string S = "";
char[] chars = Q.ToCharArray();
for (int R = 0; R < P; R++) {
char T = chars[R];
if (Regex.IsMatch(T.ToString(),"[a-zA-Z0-9]")) {
int U = H[chars[R]] - M;
if (U < 0) {
U += 62 ;
}
T = (char)(K[U]);//String.fromCharCode
}
S += T;
}
return S;
}
}