✎
编程开发网
首页
C语言
C++
面试
Linux
函数
Windows
数据库
下载
搜索
当前位置:
首页
->
基础
->
c++编程基础
单点登陆 (五)
2014-11-23 23:40:09
·
作者:
·
浏览:
53
标签:
单点
登陆
()) { return client.Channel.GetShopCartQtyByUserID(UserID); } } catch (Exception ex) { Log.WriteLog(ex); } return new List
(); } ///
/// 获取购物车数量 ///
///
public static IList
GetShopCartQtyByUserID() { if (IsLogin()) { return GetShopCartQtyByUserID(UserInfo.UserBaseID); } return new List
(); } ///
/// 申请店铺流程过程中直接录入地址时未满足条件url跳转 ///
public static void RedirectAlertPage() { //Response.Redirect(ConfigHelper.GetDomain("LoginURL") + "/AlertPage.
asp
x"); HttpContext.Current.Response.Redirect(ConfigHelper.GetDomain("LoginURL") + "AlertPage.aspx"); } #region
加密
解密 //默认密钥向量 private static byte[] Keys = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF }; /**/ /**/ /**/ private static DESCryptoServiceProvider des = new DESCryptoServiceProvider(); ///
/// DES加密字符串 ///
///
待加密的字符串 ///
加密密钥,要求为8位 ///
加密成功返回加密后的字符串,失败返回源串
public static string EncryptDES(string encryptString, string encryptKey) { try { //byte[] rgbKey = Encoding.UTF8.GetBytes(encryptKey.Substring(0, 8)); //byte[] rgbIV = Keys; //byte[] inputByteArray = Encoding.UTF8.GetBytes(encryptString); //DESCryptoServiceProvider dCSP = new DESCryptoServiceProvider(); //MemoryStream mStream = new MemoryStream(); //CryptoStream cStream = new CryptoStream(mStream, dCSP.CreateEncryptor(rgbKey, rgbIV), CryptoStreamMode.Write); //cStream.Write(inputByteArray, 0, inputByteArray.Length); //cStream.FlushFinalBlock(); //return Convert.ToBase64String(mStream.ToArray()); byte[] inputByteArray = Encoding.GetEncoding("UTF-8").GetBytes(encryptString); des.Key = ASCIIEncoding.ASCII.GetBytes(encryptKey.Substring(0, 8)); des.IV = ASCIIEncoding.ASCII.GetBytes(encryptKey.Substring(0, 8)); MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write); cs.Write(inputByteArray, 0, inputByteArray.Length); cs.FlushFinalBlock(); StringBuilder ret = new StringBuilder(); foreach (byte b in ms.ToArray()) { ret.AppendFormat("{0:X2}", b); } return ret.ToString(); } catch (Exception ex) { Log.WriteLog(ex); return encryptString; } } /**/ /**/ /**/ ///
/// DES解密字符串 ///
///
待解密的字符串 ///
解密密钥,要求为8位,和加密密钥相同 ///
解密成功返回解密后的字符串,失败返源串
public static string DecryptDES(string decryptString, string decryptKey) { try { //byte[] rgbKey = Encoding.UTF8.GetBytes(decryptKey.Substring(0, 8)); //byte[] rgbIV = Keys; //byte[] inputByteArray = Convert.FromBase64String(decryptString); //DESCryptoServiceProvider DCSP = new DESCryptoServiceProvider(); //MemoryStream mStream = new MemoryStream(); //CryptoStream cStream = new CryptoStream(mStream, DCSP.CreateDecryptor(rgbKey, rgbIV), CryptoStreamMode.Write); //cStream.Write(inputByteArray, 0, inputByteArray.Length); //cStream.FlushFinalBlock(); //return Encoding.UTF8.GetString(mStream.ToArray()); byte[] inputByteArray = new byte[decryptString.Length / 2]; for (int x = 0; x < decryptString.Length / 2; x++) { int i = (Convert.ToInt32(decryptString.Substring(x * 2, 2), 16)); inputByteArray[x] = (byte)i; } des.Key = ASCIIEncoding.ASCII.GetBytes(decryptKey.Substring(0, 8)); des.IV = ASCIIEncoding.ASCII.GetBytes(decryptKey.Substring(0, 8)); MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Write); cs.Write(inputByteArray, 0, inputByteArray.Length); cs.FlushFinalBlock(); StringBuilder ret = new StringBuilder(); return System.Text.Encoding.UTF8.GetString(ms.ToArray()); } catch (Exception ex) { Log.WriteLog(ex); return decryptString; } } ///
/// RSA 的密钥产生 产生私钥 和公钥 ///
///
///
public void RSAKey(out string xmlKeys, out string xmlPublicKey) { System.Security.Cryptography.RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); xmlKeys = rsa.ToXmlString(true); xmlPublicKey = rsa.ToX
首页
上一页
2
3
4
5
6
7
下一页
尾页
5
/7/7