先用python 做一个文本文件  (一个学号列表)


python 代码:

[root@localhost kuing]# cat input.py

#!/usr/bin/env python

f = open('design.txt','w+')

for i in range(10001,200001):

  f.write('%d\n' %i)

f.close()


没错  就是这么简单...


然后就是这些东西..


...

199998

199999

200000


接下来 写c语言代码:

 

[root@localhost kuing]# cat input.c

#include<stdio.h>

#include<stdlib.h>

int main(){

  FILE *fp;

  FILE *temp; 

  char filename[30];

  char ch;

  char strbuf[256];

  printf("please input your filename:");

  gets(filename);

  filename[29] = '\n';

  if ((fp = fopen(filename,"rb")) == NULL){

      printf("error!\n");

      return -1;

      }


  if ((temp = fopen("temp.txt","wb+")) == NULL){

     printf("create file error!\n");

     }

  

while(!feof(fp)){

   ch = fgetc(fp);

   if((int)ch != 0 && (int)ch != 0){

    ch = ~ch;

    ch = ch << 5;

    fputc(ch,temp);

    }

}

  fclose(temp);

  fclose(fp);

  sprintf(strbuf,"rm %s",filename);

  system(strbuf);

  sprintf(strbuf,"mv temp.txt %s",filename);

  system(strbuf);

  return 0;

}


然后用在Linux系统下 用gcc编译 的时候  出现gets警告轻忽略  Linux下是不建议这种写法的

但是 如果换成 fgets() 又要解决符号问题  比较麻烦   所以请忽略..


然后 运行

请输入要加密的文件

 

[root@localhost kuing]# ./input

please input your filename:design.txt

...



加密后类似于这样..


φφφφφφφǐφǎφφφφǐφǐφǐφǐφǐφǎφǎφǎφωǎφχǎφǎφǎφǎφǎφǎφφφφφφφφφφφφφˋφˉφˇφφφφφφφφφφφφφφφφǐφǎφφφ ...



其实这就是这把字符按位取反  如果程序反过来运行一下  就会解密其中的内容..


..