当前位置:天才代写 > tutorial > C语言/C++ 教程 > C 利用异或(xor)加密/解密文件

C 利用异或(xor)加密/解密文件

2017-11-01 08:00 星期三 所属: C语言/C++ 教程 浏览:780

之前写过一篇《php 利用异或(XOR)加密/解密文件》,但php执行的速度很慢,因此这次利用C重写,速度有很大的提高。

xor_encrypt.c

/** XOR 加密/解密文件 */
      
#define TRUE 1  
#define FALSE 0  
      
#include <stdio.h>  
#include <stdlib.h>  
#include <string.h>  
#include <io.h>     // 假如在/usr/include/找不到,可以在/usr/include/sys/复制已往  
      
      
// 输出信息  
void msg_log(char *str);  
      
// 判定文件是否存在  
int file_exists(char *filename);  
      
      
// 主函数
//
fdipzone@ubuntu:~/C$ gcc -o xor_encrypt xor_encrypt.c  
fdipzone@ubuntu:~/C$ time ./xor_encrypt 1280.jpg 1280en.jpg '@#$%^&*()_DFGHJKadsklfjasdf'  
success  
      
real    0m0.139s  
user    0m0.060s  
sys 0m0.070s

From:csdn博客 傲雪星枫

 

    关键字:

天才代写-代写联系方式