C语言编写随机加密程序

 时间:2026-02-13 11:49:16

1、首先打开VC++6.0

C语言编写随机加密程序

2、选择文件,新建

C语言编写随机加密程序

3、选择C++ source file 新建一个空白文档

C语言编写随机加密程序

4、声明头文件

#include<stdio.h>

#include<stdlib.h>

5、主函数

#include<stdlib.h>

int main()

{

FILE * sourcefile;

FILE * keyfile;

FILE * destfile;

char ch,keych;

int i;

puts("****************************************");

puts("* The file will encrypt the source.txt *");

puts("****************************************");

if(!(sourcefile = fopen("source.txt","r")))

{

 printf("Can not open the source file\n");

 exit(-1);

}

if(!(destfile = fopen("destfile.txt","w+")))

{

 printf("Can not open the destination  file\n");

 exit(-1);

}

if(!(keyfile= fopen("keyfile.txt","w+")))

{

 printf("Can not open the keyfile  file\n");

 exit(-1);

}

printf("\n.....Encrypting....\n");

i = 0;

while(!feof(sourcefile))

{

randomize();

keych = random(112 - i) +16;

ch = fgetc(sourcefile);

 ch = ch ^ keych;

 fputc(ch,destfile);

fputc(keych,keyfile);

i = ( ++i)%16;

}

printf("Encrypted the souce.txt successfully!\n");

fclose(sourcefile);

fclose(keyfile);

fclose(destfile);

getch();

return 1;

}


  • c语言if elseif使用例子。
  • C语言“素数”代码教程
  • 常用曲线有哪些?
  • 金工实习的作用
  • 怎样用C++进行矩阵转置
  • 热门搜索
    小学生国庆节手抄报 好看的手抄报图片大全 世界地球日手抄报图片 呵护心灵手抄报资料 动物手抄报大全 三年级重阳节手抄报 国庆节手抄报简单又好画 春的手抄报 安全手抄报内容大全 手抄报版面设计图简单的