C++ encryption and decryption algorithm is replaced by java method

There are two c++ files, which contain encryption and decryption algorithms. I ask God to implement the encryption and decryption algorithms in java.
File Crypt.h

#if defined (AFX_CRYPT_H__613C5174_16F0_42A5_9493_C7489534C080__INCLUDED_)! #Define
AFX_CRYPT_H__613C5174_16F0_42A5_9493_C7489534C080__INCLUDED_

#if _MSC_VER> 1000
#pragma
Once #endif // _MSC_VER> 1000

class ccrypt 
{
static char * M_Key;
public:
static CString the decrypt (CString str);
static CString the encrypt (CString str);
};

#endif // !defined(AFX_CRYPT_H__613C5174_16F0_42A5_9493_C7489534C080__INCLUDED_)

File Crypt.cpp

#include "stdafx.h"
#include "crypt.h"

#include <atlconv.h>

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Konstruktion/Destruktion
//////////////////////////////////////////////////////////////////////

char* CCrypt::m_key = "FILEZILLA1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";

CString CCrypt::encrypt(CString str)
{
USES_CONVERSION;
int pos=str.GetLength()%strlen(m_key);
CString ret;
LPCSTR lpszAscii=T2CA(str);
for (unsigned int i=0;i<strlen(lpszAscii);i++)
{
CString tmp=ret;
ret.Format(_T("%s%03d"),tmp,(unsigned char)lpszAscii[i]^m_key[(i+pos)%strlen(m_key)]);
}
return ret;
}

CString CCrypt::decrypt(CString str)
{
USES_CONVERSION;

LPCSTR lpszAscii=T2CA(str);
int pos=(strlen(lpszAscii)/3)%strlen(m_key);
CString ret;
char buffer[4];
buffer[3]=0;
for (unsigned int i=0;i<strlen(lpszAscii)/3;i++)
{
memcpy(buffer,lpszAscii+i*3,3);
TCHAR tmp[2];
tmp[1]=0;
tmp[0]=atoi(buffer)^m_key[(i+pos)%strlen(m_key)];
ret+=tmp;
}
return ret;
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326396552&siteId=291194637