您的位置:首页 > 其它

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

2016-08-05 10:55 561 查看
随机复写硬盘,可以防止一般的数据恢复???

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define FILE_SIZE        ( 1024 * 1024 * 1 )
#define FILE_COUNT        ( 1 * 100 )
#define FCK_LOOP        ( 3 )

int main(void)
{
FILE *fp = NULL;
char file_name[32];
unsigned char *data = NULL;
int i, j, len, fck_loop;

data = (unsigned char *)malloc(FILE_SIZE);
if(data == NULL)
{
printf("malloc %d error!!\n", i);
goto end;
}

fck_loop = 0;
while(fck_loop < FCK_LOOP)
{
//for(i = 0; i < FILE_COUNT; i++)
i = 0;
while(1)
{
if(fck_loop == 0)
{
memset(data, 0x00, FILE_SIZE);
}
else if(fck_loop == 1)
{
memset(data, 0xff, FILE_SIZE);
}
else
{
srand(i ^ 0x835);

for(j = 0; j < FILE_SIZE; j++)
{
data[j] = rand() % 0xff;
}
}

snprintf(file_name, sizeof(file_name)-1, "fck_file_%08d", i);
printf("%s\n", file_name);

fp = fopen(file_name, "w+");
if(fp == NULL)
{
printf("create %s error!!\n", file_name);
//goto end;
break;
}

len = fwrite(data, 1, FILE_SIZE, fp);
//printf("fwrite len: %d\n", len);
if(len != FILE_SIZE * 1)
{
printf("write %s error!!\n", file_name);
//goto end;
break;
}

fclose(fp);
i++;
}
system("del fck_file_*");
fck_loop++;
}
free(data);

end:
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: