将文件划分为固定长度的分块 [英] Divide File into fixed length chunking

查看:136
本文介绍了将文件划分为固定长度的分块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,我需要您的帮助
我需要固定长度分块的ac程序实现(将文件分成固定大小的块,例如8kb,并使用哈希值MD5或SHA1计算每个块的哈希)...找到相同的哈希后,将块视为冗余:否则存储块及其哈希...

hii friend, i need your help
I need a c program implementation for fixed length chunking (file divided into fixed size block for ex. 8kb and use the hash value, MD5 or SHA1 to calculate hash for each block)... once a same hash is found, consider the chunk as redundancy: otherwise store the chunk and its hash...

推荐答案

Set a variable to the total size of the file
REPEAT:
if file size is greater than chunk size
    Read the next chunk
else
    Read the remaining data
Compute the hash for this chunk
Process the chunk and hash ... not sure what you mean here
Subtract last block size from total file size
If total file size greater than zero go back to REPEAT:


好吧,毕竟您的要求很明确.
您对此有何疑问?
棘手的部分"正在计算哈希值,但是您可以找到该哈希值的免费代码(例如 ^ ]).
Well, your requirements are clear, after all.
What is you doubt about?
The ''tricky part'' is computing the hash value but you may find freely available code for that (e.g. MD5[^]).


这篇关于将文件划分为固定长度的分块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆