2023-05-24 04:16:07 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
|
|
namespace ITC81DB_0H.Part11_Encryption
|
|
|
|
|
{
|
|
|
|
|
public partial class Encryption
|
|
|
|
|
{
|
|
|
|
|
public delegate void ObjectEventHandler(object data);
|
|
|
|
|
public static event ObjectEventHandler DllAesEncryption_Event;
|
2023-07-24 04:23:49 +00:00
|
|
|
|
public static event ObjectEventHandler DllAesEncryption_GetVersionDataEvent;
|
2023-05-24 04:16:07 +00:00
|
|
|
|
|
|
|
|
|
public static void InitializeEncryption()
|
|
|
|
|
{
|
|
|
|
|
// register callback
|
2023-07-24 04:23:49 +00:00
|
|
|
|
fnAesVersionCallBack = AesEncryption_VersionCallback;
|
|
|
|
|
DLL_AES_Register_VersionCB(fnAesVersionCallBack);
|
|
|
|
|
|
2023-05-24 04:16:07 +00:00
|
|
|
|
fnAesEncryptionCallBack = cbAesEncryption;
|
|
|
|
|
DLL_AES_Register_EncryptionCB(fnAesEncryptionCallBack);
|
|
|
|
|
|
|
|
|
|
// call the function
|
|
|
|
|
DLL_AES_Activation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region Aes_Fuction
|
|
|
|
|
public static void fAesEncryption(string inFileName, string outFileName, bool encrypt, bool compress)
|
|
|
|
|
{
|
|
|
|
|
IntPtr pInFileName = Marshal.StringToBSTR(inFileName);
|
|
|
|
|
IntPtr pOutFileName = Marshal.StringToBSTR(outFileName);
|
|
|
|
|
|
|
|
|
|
DLL_AES_Encryption(pInFileName, pOutFileName, encrypt, compress);
|
|
|
|
|
}
|
2023-07-24 04:23:49 +00:00
|
|
|
|
public static void AesEncryption_GetVersion()
|
|
|
|
|
{
|
|
|
|
|
DLL_SAES_Getversion();
|
|
|
|
|
}
|
2023-05-24 04:16:07 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Aes_Callback
|
|
|
|
|
public static void cbAesEncryption(ref auth_encryption_status_t encryption_status)
|
|
|
|
|
{
|
|
|
|
|
if (DllAesEncryption_Event != null)
|
|
|
|
|
DllAesEncryption_Event(encryption_status);
|
|
|
|
|
}
|
2023-07-24 04:23:49 +00:00
|
|
|
|
private static void AesEncryption_VersionCallback(StringBuilder version)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (DllAesEncryption_GetVersionDataEvent != null)
|
|
|
|
|
DllAesEncryption_GetVersionDataEvent(version);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-24 04:16:07 +00:00
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|