@@ -16,7 +16,7 @@ | |||||
<input id="FUrl" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" /> | <input id="FUrl" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" /> | ||||
</div> | </div> | ||||
<div class="col-xs-12 lr-form-item" data-table="Perm_Function"> | <div class="col-xs-12 lr-form-item" data-table="Perm_Function"> | ||||
<div class="lr-form-item-title">登录接口地址<font face="宋体">*</font></div> | |||||
<div class="lr-form-item-title">退出地址<font face="宋体">*</font></div> | |||||
<input id="FInterfaceUrl" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" /> | <input id="FInterfaceUrl" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" /> | ||||
</div> | </div> | ||||
<div class="col-xs-12 lr-form-item" data-table="Perm_Function" style="display: none;" id="divFId"> | <div class="col-xs-12 lr-form-item" data-table="Perm_Function" style="display: none;" id="divFId"> | ||||
@@ -96,11 +96,11 @@ namespace Learun.Application.Web.Controllers | |||||
var url = perm_application.FInterfaceUrl; | var url = perm_application.FInterfaceUrl; | ||||
if (url.Contains("?")) | if (url.Contains("?")) | ||||
{ | { | ||||
url += "&appkey=" + DESEncrypt.Encrypt(code, "bjqjsso"); | |||||
url += "&appkey=" + Md5Helper.Encrypt(perm_application.FSecret, 32) + "&name=" + DESEncrypt.Encrypt(userinfo.realName, perm_application.FSecret, false) + "&no=" + DESEncrypt.Encrypt(userinfo.enCode, perm_application.FSecret, false) + "&no=" + DESEncrypt.Encrypt(userinfo.enCode); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
url += "?appkey=" + DESEncrypt.Encrypt(code, "bjqjsso"); | |||||
url += "?appkey=" + Md5Helper.Encrypt(perm_application.FSecret, 32) + "&name=" + DESEncrypt.Encrypt(userinfo.realName, perm_application.FSecret, false) + "&no=" + DESEncrypt.Encrypt(userinfo.enCode, perm_application.FSecret, false) + "&no=" + DESEncrypt.Encrypt(userinfo.enCode); | |||||
} | } | ||||
return Redirect(url); | return Redirect(url); | ||||
} | } | ||||
@@ -153,14 +153,19 @@ namespace Learun.Application.WebApi.Modules | |||||
//写入当前请求所登录的用户 | //写入当前请求所登录的用户 | ||||
var code = Util.CommonHelper.RndNum(9); | var code = Util.CommonHelper.RndNum(9); | ||||
cache.Write(code, userinfo.account, TimeSpan.FromMinutes(10)); | cache.Write(code, userinfo.account, TimeSpan.FromMinutes(10)); | ||||
string tyrz = ConfigurationManager.AppSettings["tyrz"]; | |||||
if (!perm_application.FSecret.IsEmpty()) | |||||
{ | |||||
tyrz = perm_application.FSecret; | |||||
} | |||||
var url = perm_application.FInterfaceUrl; | var url = perm_application.FInterfaceUrl; | ||||
if (url.Contains("?")) | if (url.Contains("?")) | ||||
{ | { | ||||
url += "&appkey=" + DESEncrypt.Encrypt(code, "bjqjsso"); | |||||
url += "&appkey=" + Md5Helper.Encrypt("tyrz", 32) + "&name=" + DESEncrypt.Encrypt(userinfo.realName, "tyrz") + "&no=" + DESEncrypt.Encrypt(userinfo.enCode, "tyrz"); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
url += "?appkey=" + DESEncrypt.Encrypt(code, "bjqjsso"); | |||||
url += "?appkey=" + Md5Helper.Encrypt("tyrz", 32) + "&name=" + DESEncrypt.Encrypt(userinfo.realName, "tyrz") + "&no=" + DESEncrypt.Encrypt(userinfo.enCode, "tyrz"); | |||||
} | } | ||||
return Success(new{ FInterfaceUrl=url }); | return Success(new{ FInterfaceUrl=url }); | ||||
} | } | ||||
@@ -31,13 +31,20 @@ namespace Learun.Util | |||||
/// <param name="Text">需要加密的内容</param> | /// <param name="Text">需要加密的内容</param> | ||||
/// <param name="sKey">秘钥</param> | /// <param name="sKey">秘钥</param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
public static string Encrypt(string Text, string sKey) | |||||
public static string Encrypt(string Text, string sKey, bool md5 = true) | |||||
{ | { | ||||
var key = sKey; | |||||
var iv = sKey; | |||||
if (md5) | |||||
{ | |||||
key = Md5Helper.Hash(sKey).ToUpper().Substring(0, 8); | |||||
iv = Md5Helper.Hash(sKey).ToUpper().Substring(0, 8); | |||||
} | |||||
DESCryptoServiceProvider des = new DESCryptoServiceProvider(); | DESCryptoServiceProvider des = new DESCryptoServiceProvider(); | ||||
byte[] inputByteArray; | byte[] inputByteArray; | ||||
inputByteArray = Encoding.Default.GetBytes(Text); | inputByteArray = Encoding.Default.GetBytes(Text); | ||||
des.Key = ASCIIEncoding.ASCII.GetBytes(Md5Helper.Hash(sKey).ToUpper().Substring(0, 8)); | |||||
des.IV = ASCIIEncoding.ASCII.GetBytes(Md5Helper.Hash(sKey).ToUpper().Substring(0, 8)); | |||||
des.Key = ASCIIEncoding.ASCII.GetBytes(key); | |||||
des.IV = ASCIIEncoding.ASCII.GetBytes(iv); | |||||
System.IO.MemoryStream ms = new System.IO.MemoryStream(); | System.IO.MemoryStream ms = new System.IO.MemoryStream(); | ||||
CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write); | CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write); | ||||
cs.Write(inputByteArray, 0, inputByteArray.Length); | cs.Write(inputByteArray, 0, inputByteArray.Length); | ||||
@@ -75,8 +82,15 @@ namespace Learun.Util | |||||
/// <param name="Text">需要解密的内容</param> | /// <param name="Text">需要解密的内容</param> | ||||
/// <param name="sKey">秘钥</param> | /// <param name="sKey">秘钥</param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
public static string Decrypt(string Text, string sKey) | |||||
public static string Decrypt(string Text, string sKey, bool md5 = true) | |||||
{ | { | ||||
var key = sKey; | |||||
var iv = sKey; | |||||
if (md5) | |||||
{ | |||||
key = Md5Helper.Hash(sKey).ToUpper().Substring(0, 8); | |||||
iv = Md5Helper.Hash(sKey).ToUpper().Substring(0, 8); | |||||
} | |||||
DESCryptoServiceProvider des = new DESCryptoServiceProvider(); | DESCryptoServiceProvider des = new DESCryptoServiceProvider(); | ||||
int len; | int len; | ||||
len = Text.Length / 2; | len = Text.Length / 2; | ||||
@@ -87,8 +101,8 @@ namespace Learun.Util | |||||
i = Convert.ToInt32(Text.Substring(x * 2, 2), 16); | i = Convert.ToInt32(Text.Substring(x * 2, 2), 16); | ||||
inputByteArray[x] = (byte)i; | inputByteArray[x] = (byte)i; | ||||
} | } | ||||
des.Key = ASCIIEncoding.ASCII.GetBytes(Md5Helper.Hash(sKey).ToUpper().Substring(0, 8)); | |||||
des.IV = ASCIIEncoding.ASCII.GetBytes(Md5Helper.Hash(sKey).ToUpper().Substring(0, 8)); | |||||
des.Key = ASCIIEncoding.ASCII.GetBytes(key); | |||||
des.IV = ASCIIEncoding.ASCII.GetBytes(iv); | |||||
System.IO.MemoryStream ms = new System.IO.MemoryStream(); | System.IO.MemoryStream ms = new System.IO.MemoryStream(); | ||||
CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Write); | CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Write); | ||||
cs.Write(inputByteArray, 0, inputByteArray.Length); | cs.Write(inputByteArray, 0, inputByteArray.Length); | ||||