增加网站配置类,万仕达接口加密key从配置读取

This commit is contained in:
falcon 2019-03-04 10:04:25 +08:00
parent bb286f8f58
commit 817e244ee9
4 changed files with 33 additions and 1 deletions

View File

@ -76,7 +76,7 @@ namespace Cmdjy.Bll
/// </summary> /// </summary>
public static DesHelper GetHelper() { public static DesHelper GetHelper() {
if(_deshelper == null) { if(_deshelper == null) {
var key = ""; var key = WebSettings.DesKey;
byte[] IV = { 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08 }; byte[] IV = { 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08 };
_deshelper = GetHelper(PaddingMode.PKCS7,CipherMode.CBC,IV,key); _deshelper = GetHelper(PaddingMode.PKCS7,CipherMode.CBC,IV,key);

View File

@ -165,6 +165,7 @@
<DependentUpon>Global.asax</DependentUpon> <DependentUpon>Global.asax</DependentUpon>
</Compile> </Compile>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WebSettings.cs" />
<Compile Include="ws\HisInterface.asmx.cs"> <Compile Include="ws\HisInterface.asmx.cs">
<DependentUpon>HisInterface.asmx</DependentUpon> <DependentUpon>HisInterface.asmx</DependentUpon>
<SubType>Component</SubType> <SubType>Component</SubType>

View File

@ -13,6 +13,10 @@
<add key="webpages:Enabled" value="false" /> <add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" /> <add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" /> <add key="UnobtrusiveJavaScriptEnabled" value="true" />
<!--双方协商需要8位长度超过8位取8位小于8位抛出异常-->
<add key="DesKey" value="wsddjy19"/>
</appSettings> </appSettings>
<connectionStrings> <connectionStrings>
<add name="DjyDbContext" <add name="DjyDbContext"

View File

@ -0,0 +1,27 @@
using System;
using System.Configuration;
namespace Cmdjy
{
/// <summary>
/// 网站配置
/// </summary>
public static class WebSettings
{
/// <summary>
/// 获取配置的值
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static string GetValue(String key) {
var val = ConfigurationManager.AppSettings[key];
return val;
}
/// <summary>
/// 万仕达加密通信用的的加密key
/// </summary>
public static string DesKey {
get => GetValue("DesKey") ?? throw new Exception("必须在web.config文件appSettings节配置DesKey的值");
}
}
}