


简单的加密解密算法
这个小程序是用来作为一个非常简单的对称加密算法,比移位加密稍微强那么一点点。
seed的话大家可以自己来设置,seed大概为60位,程序没有边界检查,很简陋,希望看官们别见笑。
// Code.h: interface for the CCode class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_CODE_H__D5B90563_053E_4256_A61D_7D56F8FB20CF__INCLUDED_) #define AFX_CODE_H__D5B90563_053E_4256_A61D_7D56F8FB20CF__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 class CCode { public: CString Decode(CString strCode); CString Encode(CString strCode); CCode(); virtual ~CCode(); private: CString EnDeCode(CString strCode); int iLength; char* szSeed2; }; #endif // !defined(AFX_CODE_H__D5B90563_053E_4256_A61D_7D56F8FB20CF__INCLUDED_)
// Code.cpp: implementation of the CCode class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "DecodeEncode.h" #include "Code.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CCode::CCode() { iLength = 0; char strTemp[60] ={0x04,0x02,0x06,0x05,0x01,0x09,0x03,0x07,0x08,0x02,\ 0x04,0x02,0x06,0x05,0x01,0x09,0x03,0x07,0x08,0x02,\ 0x04,0x02,0x06,0x05,0x01,0x09,0x03,0x07,0x08,0x02,\ 0x04,0x02,0x06,0x05,0x01,0x09,0x03,0x07,0x08,0x02,\ 0x04,0x02,0x06,0x05,0x01,0x09,0x03,0x07,0x08,0x02,\ 0x04,0x02,0x06,0x05,0x01,0x09,0x03,0x07,0x08,0x02}; szSeed2 = new char[60]; memcpy(szSeed2,strTemp,60); } CCode::~CCode() { delete[] szSeed2; } CString CCode::Encode(CString strCode) { return EnDeCode(strCode); } CString CCode::Decode(CString strCode) { return EnDeCode(strCode); } CString CCode::EnDeCode( CString strCode ) { LPCTSTR szSource = (LPCTSTR) strCode; iLength = strCode.GetLength(); char *szSeed = new char[iLength]; memcpy(szSeed,szSeed2,iLength); char * szSr = new char[iLength]; char *szDes = new char[iLength + 1]; memcpy(szSr,szSource,iLength); for(int i = 0;i < iLength;i++) { szDes[i] = szSr[i] ^szSeed[i] ; } szDes[iLength] = '\0'; CString strTemp(szDes); delete[] szSr; delete[] szDes; delete[] szSeed; return strTemp; }
整个程序使用起来很简单,就是调用一下加密解密就行了。
The above is the detailed content of Introduction to implementing MFC's simple encryption and decryption applet. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Linux new version
SublimeText3 Linux latest version

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft
