gpt4 book ai didi

c - 从 .txt 字符中减去添加的数字不会反向加密?

转载 作者:太空宇宙 更新时间:2023-11-04 04:14:09 25 4
gpt4 key购买 nike

当加密一个文本文件然后用“字节 key ”运行算法来撤销加密时,它只是改变了困惑的文本,实际上并没有反转任何东西。我缺少某些概念吗?

void encrypt(char filePath[],int key) {
FILE * file;
char byte;
file = fopen(filePath,"r+");
while( (byte = fgetc(file)) != EOF) {
fputc(byte+key,file);
}
fclose(file);
}

最佳答案

这是我的新加密函数的样子

void encrypt(char filePath[],int key) {
FILE * fileR;
FILE * fileW;
char dest[500],src[4];
int byte;
fileR = fopen(filePath,"r");
//Combines filePath with ext for unique filename
strcpy(dest,filePath);
strcpy(src,ext);
fileW = fopen(strcat(dest,src),"w");
while( (byte = fgetc(fileR)) != EOF) {
fputc(byte+key,fileW);
}
fclose(fileR);
fclose(fileW);
}

它现在按预期工作。

关于c - 从 .txt 字符中减去添加的数字不会反向加密?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53735420/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com