111,119
社区成员
发帖
与我相关
我的任务
分享
typedef unsigned long DWORD;
typedef unsigned char UCHAR,*PUCHAR;
typedef void *PVOID,*LPVOID;
typedef unsigned char byte;
typedef DWORD *PDWORD,*LPDWORD;
DWORD TAesClass::OnAesEncrypt(LPVOID InBuffer,DWORD InLength,LPVOID OutBuffer)
{
DWORD OutLength=0;
if (m_lpAes==NULL||OutBuffer==NULL)
{
return 0;
}
UCHAR *lpCurInBuff=(UCHAR *)InBuffer;
UCHAR *lpCurOutBuff=(UCHAR *)OutBuffer;
long blocknum=InLength/16;
long leftnum=InLength%16;
for(long i=0;i<blocknum;i++)
{
m_lpAes->Cipher(lpCurInBuff,lpCurOutBuff);
lpCurInBuff+=16;
lpCurOutBuff+=16;
OutLength+=16;
}
if(leftnum)
{
UCHAR inbuff[16];
memset(inbuff,0,16);
memcpy(inbuff,lpCurInBuff,leftnum);
m_lpAes->Cipher(inbuff,lpCurOutBuff);
lpCurOutBuff+=16;
OutLength+=16;
}
UCHAR extrabuff[16];
memset(extrabuff,0,16);
*((LPDWORD)extrabuff)=16+(16-leftnum)%16;
m_lpAes->Cipher(extrabuff,lpCurOutBuff);
OutLength+=16;
return OutLength;
}
private ulong TAesClass.OnAesEncrypt(ulong InBuffer, uint InLength, ulong OutBuffer)
{
ulong OutLength = 0;
if (TAesClass.m_lpAes == null || OutBuffer == null)
{
return 0;
}
Byte lpCurInBuff = (Byte)InBuffer;
Byte lpCurOutBuff = (Byte)OutBuffer;
long blocknum = InLength / 16;
long leftnum = InLength % 16;
for(int i =0;i<blocknum;i++)
{
lpCurInBuff+=16;
lpCurOutBuff+=16;
OutLength+=16;
}
if (leftnum != 0)
{
Byte[] inbuff = new Byte[16];
//这里应该怎么转
lpCurOutBuff+=16;
OutLength+=16;
}
Byte[] extrabuff = new Byte[16];
extrabuff = 16 + (16 - leftnum) % 16;
OutLength+=16;
return OutLength;
}
这个是C++的,但是在C#中应该是怎样的啊