/// <summary> /// 使用SecretKey对数据data进行解密 /// </summary> /// <param name="data">待解密的数据</param> /// <param name="SecretKey">解密密码串</param> /// <returns></returns> public static string Decrypt(string data, string SecretKey) { try { string key = MD5.Encrypt(SecretKey);// 7f01583d4ae071a9e39ffc18e3a12d9f StringBuilder builder = new StringBuilder(); int i = 0; foreach (char A in data) // 663r6uf0cew7cr5d9g08pnitiy7c9mi7ut8u98615nc1fkzp { if (i >= key.Length) { i = i % key.Length; key = MD5.Encrypt(key); } char B = key[i++]; char n = ToChar(ToInt(A) - ToInt(B) * 3); builder.Append(n); } data = builder.ToString(); data = EncoderTool_Alphabet.DecodeAlphabet(data); } catch (Exception ex) { } return(data); }
/// <summary> /// 使用SecretKey对数据data进行加密 /// </summary> /// <param name="data">待加密的数据</param> /// <param name="SecretKey">自定义密码串</param> /// <returns></returns> public static string Encrypt(string data, string SecretKey) { string key = MD5.Encrypt(SecretKey); // 7f01583d4ae071a9e39ffc18e3a12d9f data = EncoderTool_Alphabet.EncodeAlphabet(data); StringBuilder builder = new StringBuilder(); int i = 0; foreach (char A in data) // ofloifofikkaofkpigohjkieogjflaoginkooelpkbogibkp" { if (i >= key.Length) { i = i % key.Length; key = MD5.Encrypt(key); // 变换新的key } char B = key[i++]; char n = ToChar(ToInt(A) + ToInt(B) * 3); builder.Append(n); } return(builder.ToString()); }