First use Python to make a text file (a study number list)
Python code:
[email protected] 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 ()
Yes, that's so simple ...
And then there's these things.
...
199998
199999
200000
Next write the C language code:
[email protected] 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;
}
Then use the Linux system to compile with GCC when the get warning light ignore Linux is not recommended this writing
However, if you change to fgets () and solve the problem of symbols is more troublesome, please ignore:
And then run
Please enter the file you want to encrypt
[Email protected] kuing]#./input
Please input your filename:design.txt
...
After encryption is similar to this:
Φφφφφφφǐφǎφφφφǐφǐφǐφǐφǐφǎφǎφǎφωǎφχǎφǎφǎφǎφǎφǎφφφφφφφφφφφφφˋφˉφˇφφφφφφφφφφφφφφφφǐφǎφφφ ...
Actually, that's what this is about. If the program runs in turn, it will decrypt the contents of the string.
..
This article is from the "Kuing Home pages" blog, so be sure to keep this source http://kuing.blog.51cto.com/9635522/1759998
C language implementation of simple text file encryption---Preliminary