Username:用户名,采用AZDG加密方式进行加密
Passwrod:密码,采用AZDG加密方式进行加密
密钥为:chinagdn
////// 短信发送AZDG加密算法 /// /// 加密字符串 /// 私有密钥 ///public static string passport_encrypt(string txt, string key) { // 使用随机数产生 0~32000 的值并 MD5() Random rnd = new Random(100); int int_encrypt_key = rnd.Next(0, 32000); string encrypt_key = int_encrypt_key.ToString(); int ctr = 0; string tmp = ""; byte[] encodebyte = new byte[txt.Length]; for (int i = 0; i < txt.Length; i++) { ctr = ctr == encrypt_key.Length ? 0 : ctr; char prefix = encrypt_key[ctr]; char left = txt[i]; char right = encrypt_key[ctr++]; encodebyte[i] = (byte)(left ^ right); char[] block = new char[2]; block[0] = prefix; block[1] = Convert.ToChar(encodebyte[i]); tmp += new string(block); } //用base64编码 string complicatedstring = passport_key(tmp, key);//先和key加一次密? byte[] inputbytes = System.Text.Encoding.Default.GetBytes(complicatedstring); string string_64 = Convert.ToBase64String(inputbytes, 0, inputbytes.Length);//再和随机key加密 return string_64; } /// /// Passport 解密函数 /// /// 加密后的字串 /// 私有密匙(用于解密和加密) ///字串经过私有密匙解密后的结果 public static string passport_decrypt(string txt, string key) { byte[] array_64 = Convert.FromBase64String(txt); string txt_64 = System.Text.Encoding.Default.GetString(array_64); txt = passport_key(txt_64, key); string temp = ""; byte[] encodebyte = new byte[txt.Length]; for (int i = 0; i < txt.Length; i++) { char left = txt[i]; char right = txt[++i]; encodebyte[i] = (byte)(left ^ right); } temp = System.Text.Encoding.Default.GetString(encodebyte); return temp; } ////// Passport 密匙处理函数 /// /// 待加密或待解密的字串 /// 私有密匙(用于解密和加密) ///处理后的密匙 public static string passport_key(string txt, string encrypt_key) { //先md5编码 encrypt_key = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(encrypt_key, "MD5").ToString().ToLower(); int ctr = 0; string tmp = ""; byte[] encodebyte = new byte[txt.Length]; for (int i = 0; i < txt.Length; i++) { ctr = ctr == encrypt_key.Length ? 0 : ctr; char left = txt[i]; char right = encrypt_key[ctr++]; encodebyte[i] = (byte)(left ^ right); } tmp = System.Text.Encoding.Default.GetString(encodebyte); return tmp; }
//插入下发短信 string message = smsclient.InsertDownSms(passport_encrypt(username, "chinagdn"), passport_encrypt(password, "chinagdn"), "", sb.ToString());