Files
BusinessMgr-2019/SaBusMgrStandardBase/Base/Data/SbmWindowsServiceCrypter.cs
T

48 lines
1.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:";
// --- Request Data ---
/// <summary>Encrypt request data</summary>
public static String EncryptRequestData(String value)
{
return SacsAesGcmCrypter.Encrypt(value, requestDataKey, SbmEncryptionPurpose.WindowsServiceRequest);
}
/// <summary>Decrypt request data</summary>
public static String DecryptRequestData(String value)
{
return SacsAesGcmCrypter.Decrypt(value, requestDataKey, SbmEncryptionPurpose.WindowsServiceRequest);
}
// --- Response Data ---
/// <summary>Encrypt response data</summary>
public static String EncryptResponseData(String value)
{
return SacsAesGcmCrypter.Encrypt(value, responseDataKey, SbmEncryptionPurpose.WindowsServiceResponse);
}
/// <summary>Decrypt response data</summary>
public static String DecryptResponseData(String value)
{
return SacsAesGcmCrypter.Decrypt(value, responseDataKey, SbmEncryptionPurpose.WindowsServiceResponse);
}
// --- The End ---
}
}