解密完成

This commit is contained in:
Yosin-Lenheart
2022-02-17 13:17:46 +08:00
parent b2d797c480
commit 765d63c28d
7 changed files with 71 additions and 24 deletions

24
test/RSAC.cpp Normal file
View File

@@ -0,0 +1,24 @@
#pragma once
#include "pch.h"
//单个字符异或运算
char MakecodeChar(char c, int key) {
return c = c ^ key;
}
//单个字符解密
char CutcodeChar(char c, int key) {
return c ^ key;
}
//加密
void Makecode(char* pstr, int* pkey) {
int len = strlen(pstr);//获取长度
for (int i = 0; i < len; i++)
*(pstr + i) = MakecodeChar(*(pstr + i), pkey[i % 5]);
}
//解密
void Cutecode(char* pstr, int* pkey) {
int len = strlen(pstr);
for (int i = 0; i < len; i++)
*(pstr + i) = CutcodeChar(*(pstr + i), pkey[i % 5]);
}