• 随机复写硬盘,可以防止一般的数据恢复???


    随机复写硬盘,可以防止一般的数据恢复???

     1 #include <stdio.h>
     2 #include <stdlib.h>
     3 #include <string.h>
     4 
     5 #define FILE_SIZE        ( 1024 * 1024 * 1 )
     6 #define FILE_COUNT        ( 1 * 100 )
     7 #define FCK_LOOP        ( 3 )
     8 
     9 int main(void)
    10 {
    11     FILE *fp = NULL;
    12     char file_name[32];
    13     unsigned char *data = NULL;
    14     int i, j, len, fck_loop;
    15     
    16     data = (unsigned char *)malloc(FILE_SIZE);
    17     if(data == NULL)
    18     {
    19         printf("malloc %d error!!
    ", i);
    20         goto end;
    21     }
    22     
    23     fck_loop = 0;
    24     while(fck_loop < FCK_LOOP)
    25     {
    26         //for(i = 0; i < FILE_COUNT; i++)
    27         i = 0;
    28         while(1)
    29         {
    30             if(fck_loop == 0)
    31             {
    32                 memset(data, 0x00, FILE_SIZE);
    33             }
    34             else if(fck_loop == 1)
    35             {
    36                 memset(data, 0xff, FILE_SIZE);
    37             }
    38             else
    39             {
    40                 srand(i ^ 0x835);
    41                 
    42                 for(j = 0; j < FILE_SIZE; j++)
    43                 {
    44                     data[j] = rand() % 0xff;    
    45                 }
    46             }
    47 
    48             
    49             snprintf(file_name, sizeof(file_name)-1, "fck_file_%08d", i);
    50             printf("%s
    ", file_name);
    51             
    52             fp = fopen(file_name, "w+");
    53             if(fp == NULL)
    54             {
    55                 printf("create %s error!!
    ", file_name);
    56                 //goto end;
    57                 break;
    58             }
    59             
    60             len = fwrite(data, 1, FILE_SIZE, fp);
    61             //printf("fwrite len: %d
    ", len);
    62             if(len != FILE_SIZE * 1)
    63             {
    64                 printf("write %s error!!
    ", file_name);
    65                 //goto end;
    66                 break;
    67             }
    68             
    69             fclose(fp);
    70             i++;
    71         }
    72         system("del fck_file_*");
    73         fck_loop++;
    74     }
    75     free(data);
    76     
    77 end:    
    78     return 0;
    79 }
  • 相关阅读:
    8 网站用户密码保存
    10 XSRF和XSS
    评分预测
    社会化推荐
    借助上下文信息
    UGC
    冷启动
    Git秘籍:在 Git 中进行版本回退
    Google在三大系统上停止对Chrome Apps的支持
    Windows 的 AD 域寄生于 Linux 机器
  • 原文地址:https://www.cnblogs.com/utank/p/5740439.html
Copyright © 2020-2023  润新知