70 lines
2.5 KiB
C#
70 lines
2.5 KiB
C#
using Sarand.Net.Standard.Base.App;
|
|
using Sarand.Net.Standard.Base.Data;
|
|
using System;
|
|
|
|
namespace Sarand.BusinessMgr.Net.Standard.Base.Data
|
|
{
|
|
//=======================================================================
|
|
public static class SbmWindowsServiceCrypter
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Data members.
|
|
/// <summary>
|
|
/// Encryption is shared between Windows Service app and mobile
|
|
/// </summary>
|
|
private static readonly String requestDataKey = "<Sarand>~{BusinessMgr}#[WindowsService]&/DataCryption/*|RequestData|";
|
|
private static readonly String responseDataKey = "{Sarand}+(BusinessMgr)%\\WindowsService/=<DataCryption>@:Response:";
|
|
|
|
//-------------------------------------------------------------------
|
|
// R e q u e s t D a t a
|
|
//-------------------------------------------------------------------
|
|
/// <summary>Encrypt request data</summary>
|
|
public static String EncryptRequestData(String value)
|
|
{
|
|
try
|
|
{
|
|
return SacsAesIvCrypter.Encrypt(value, requestDataKey);
|
|
}
|
|
catch (Exception exc) { SaLogger.Debug("EncryptRequestData " + exc.GetType().Name + ": " + exc.Message); }
|
|
return value;
|
|
}
|
|
/// <summary>Decrypt request data</summary>
|
|
public static String DecryptRequestData(String value)
|
|
{
|
|
try
|
|
{
|
|
return SacsAesIvCrypter.Decrypt(value, requestDataKey);
|
|
}
|
|
catch (Exception exc) { SaLogger.Debug("DecryptRequestData " + exc.GetType().Name + ": " + exc.Message); }
|
|
return value;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// R e s p o n s e D a t a
|
|
//-------------------------------------------------------------------
|
|
/// <summary>Encrypt response data</summary>
|
|
public static String EncryptResponseData(String value)
|
|
{
|
|
try
|
|
{
|
|
return SacsAesIvCrypter.Encrypt(value, responseDataKey);
|
|
}
|
|
catch (Exception exc) { SaLogger.Debug("EncryptResponseData " + exc.GetType().Name + ": " + exc.Message); }
|
|
return value;
|
|
}
|
|
/// <summary>Decrypt response data</summary>
|
|
public static String DecryptResponseData(String value)
|
|
{
|
|
try
|
|
{
|
|
return SacsAesIvCrypter.Decrypt(value, responseDataKey);
|
|
}
|
|
catch (Exception exc) { SaLogger.Debug("DecryptResponseData " + exc.GetType().Name + ": " + exc.Message); }
|
|
return value;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|