ITC81DB_2H/ITC81DB_0H/Part11_Encryption/Encryption.cs

63 lines
1.9 KiB
C#
Raw Normal View History

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;
public static event ObjectEventHandler DllAesEncryption_GetVersionDataEvent;
2023-05-24 04:16:07 +00:00
public static void InitializeEncryption()
{
// register callback
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);
}
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);
}
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
}
}