发信人: zhyy.bbs@bbs.swjtu.edu.cn (知昂), 信区: cnprogram
标  题: 用C编文件加密程序
发信站: 锦城驿站 (Wed Jan 14 22:19:41 1998)
转信站: Lilac!ustcnews!sjtunews!swjtunews!swjtubbs
出  处: xnjd21.swjtu.edu.cn

        在你建入本程序名字后面,建入想加密的文件名和加密后的文件名,
        应用此文件时再运行一次即可                                                       
        #include"stdlib.h"
        #include<stdio.h>
        main(int n,char *arg[])
        {FILE *fp1,fp2;
        char c,ch;
        long j;
        if(n!=3){printf("Error commond\n");
                exit(0);}
        if((fp1=fopen(arg[1],"rb"))==NULL)
                {printf("Can't open file\n");exit(0);}
        if((fp2=fopen(arg[2],"wb"))==NULL)
                {printf("Can't open file\n");exit(0);}
        printf("Enter password:");
        scanf("%l",&j);
        srand(j);ch=fgetc(fp1);
        while(!feof(fp1)){c=rand();ch=ch^c;fputc(ch,fp2);ch=fgetc(fp1);}
        fclose(fp1);fclose(fp2);exit(0);                       
        
        }                 

--
              ##########################################
              #                                        #
              #      生命诚可贵,爱情价更高             #
              #      若为自由故,二者皆可抛             #
              #                                        #
              ##########################################

※ 来源:.锦城驿站 bbs.swjtu.edu.cn.[FROM: 202.115.83.27]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:4.611毫秒