private static string UnEncryptString04(string CallPassword, string d) { if (CallPassword != GetCallCert()) { return(""); } if ((d == null) || (d == "") || (d.Length < 2) || (!d.StartsWith("04"))) { return(""); } d = d.Substring(2, d.Length - 2); int i; ReplaceKey_04 rk = new ReplaceKey_04(); for (i = 51; i >= 0; i--) { d = d.Replace(rk.Key[1, i], rk.Key[0, i]); } int len, Key = int.Parse(d.Substring(0, 3)); int[] Keys = new int[3]; Keys[0] = Key / 100; Keys[1] = (Key % 100) / 10; Keys[2] = (Key % 10); d = d.Substring(3, d.Length - 3); len = d.Length / 3; byte[] Byte = new byte[len]; for (i = 0; i < len; i++) { Byte[i] = (byte)(int.Parse(d.Substring(i * 3, 3)) - Keys[i % 3]); } return(System.Text.Encoding.UTF8.GetString(Byte)); }
private static string EncryptString04(string CallPassword, string s) { if (CallPassword != GetCallCert()) { return(""); } if (s == "") { return(""); } byte[] Byte = System.Text.Encoding.UTF8.GetBytes(s); int len = Byte.Length; int Key = (System.DateTime.Now.Millisecond + 200) / 2; int[] Keys = new int[3]; Keys[0] = Key / 100; Keys[1] = (Key % 100) / 10; Keys[2] = (Key % 10); string d = Key.ToString().PadLeft(3, '0'); for (int i = 0; i < len; i++) { int t = Byte[i]; t += Keys[i % 3]; d += t.ToString().PadLeft(3, '0'); } ReplaceKey_04 rk = new ReplaceKey_04(); for (int i = 0; i < 52; i++) { d = d.Replace(rk.Key[0, i], rk.Key[1, i]); } return("04" + d); }