search
HomeWeChat AppletMini Program DevelopmentIntroduction to implementing MFC's simple encryption and decryption applet

简单的加密解密算法

       这个小程序是用来作为一个非常简单的对称加密算法,比移位加密稍微强那么一点点。

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] = &#39;\0&#39;; 

    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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Clair Obscur: Expedition 33 - How To Get Perfect Chroma Catalysts
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Safe Exam Browser

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

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft