26 |
let _s x = _s "Mld_hash" x |
let _s x = _s "Mld_hash" x |
27 |
let _b x = _b "Mld_hash" x |
let _b x = _b "Mld_hash" x |
28 |
|
|
29 |
let zero = Int64.zero |
let block_size = 9728000L |
|
let one = Int64.one |
|
|
let (++) = Int64.add |
|
|
let (--) = Int64.sub |
|
|
let ( ** ) x y = Int64.mul x (Int64.of_int y) |
|
|
let ( // ) x y = Int64.div x (Int64.of_int y) |
|
|
|
|
|
let block_size = Int64.of_int 9728000 |
|
30 |
|
|
31 |
let tiger_block_size = Int64.of_int (1024 * 1024) |
let tiger_block_size = Int64.of_int (1024 * 1024) |
32 |
|
|
85 |
let tiger = TigerTree.digest_subfile fd zero file_size in |
let tiger = TigerTree.digest_subfile fd zero file_size in |
86 |
lprintf "urn:bitprint:%s.%s\n" (Sha1.to_string sha1) (TigerTree.to_string tiger); |
lprintf "urn:bitprint:%s.%s\n" (Sha1.to_string sha1) (TigerTree.to_string tiger); |
87 |
let file_size = Unix32.getsize64 fd false in |
let file_size = Unix32.getsize64 fd false in |
88 |
let nchunks = Int64.to_int (Int64.div |
let nchunks = Int64.to_int (Int64.pred file_size // tiger_block_size) + 1 in |
|
(Int64.sub file_size Int64.one) tiger_block_size) + 1 in |
|
89 |
let chunks = |
let chunks = |
90 |
let chunks = Array.create nchunks tiger in |
let chunks = Array.create nchunks tiger in |
91 |
for i = 0 to nchunks - 1 do |
for i = 0 to nchunks - 1 do |
123 |
(*************************************************************************) |
(*************************************************************************) |
124 |
|
|
125 |
let ed2k_hash_file fd file_size partial = |
let ed2k_hash_file fd file_size partial = |
126 |
let nchunks = Int64.to_int (Int64.div |
let nchunks = Int64.to_int (Int64.pred file_size // block_size) + 1 in |
|
(Int64.sub file_size Int64.one) block_size) + 1 in |
|
127 |
let md4 = if nchunks = 1 then |
let md4 = if nchunks = 1 then |
128 |
Md4.digest_subfile fd zero file_size |
Md4.digest_subfile fd zero file_size |
129 |
else |
else |
151 |
let sha1_hash_filename block_size filename = |
let sha1_hash_filename block_size filename = |
152 |
let fd = Unix32.create_rw filename in |
let fd = Unix32.create_rw filename in |
153 |
let file_size = Unix32.getsize64 fd false in |
let file_size = Unix32.getsize64 fd false in |
154 |
let nchunks = Int64.to_int (Int64.div |
let nchunks = Int64.to_int (Int64.pred file_size // block_size) + 1 in |
|
(Int64.sub file_size Int64.one) block_size) + 1 in |
|
155 |
for i = 0 to nchunks - 1 do |
for i = 0 to nchunks - 1 do |
156 |
let begin_pos = block_size ** i in |
let begin_pos = block_size ** i in |
157 |
let end_pos = begin_pos ++ block_size in |
let end_pos = begin_pos ++ block_size in |
186 |
let sig2dat_hash_filename filename partial = |
let sig2dat_hash_filename filename partial = |
187 |
let fd = Unix32.create_rw filename in |
let fd = Unix32.create_rw filename in |
188 |
let file_size = Unix32.getsize64 fd false in |
let file_size = Unix32.getsize64 fd false in |
189 |
let len64 = min (Int64.of_int 307200) file_size in |
let len64 = min 307200L file_size in |
190 |
let len = Int64.to_int len64 in |
let len = Int64.to_int len64 in |
191 |
let s = String.create len in |
let s = String.create len in |
192 |
Unix32.read fd zero s 0 len; |
Unix32.read fd zero s 0 len; |
265 |
|
|
266 |
|
|
267 |
let test_string_len64 = Int64.of_int test_string_len in |
let test_string_len64 = Int64.of_int test_string_len in |
268 |
let file_size = (Int64.of_int size) ** 1024 in |
let file_size = (Int64.of_int size) ** 1024L in |
269 |
let rec iter pos waves = |
let rec iter pos waves = |
270 |
if pos < file_size then |
if pos < file_size then |
271 |
let end_pos = min file_size (pos ++ test_string_len64) in |
let end_pos = min file_size (pos ++ test_string_len64) in |
330 |
(Printexc2.to_string e) name size) |
(Printexc2.to_string e) name size) |
331 |
file_types |
file_types |
332 |
|
|
333 |
let max_diff_size = Int64.of_int 30000000 |
let max_diff_size = 30000000L |
334 |
|
|
335 |
let diff_chunk args = |
let diff_chunk args = |
336 |
let filename1 = args.(0) in |
let filename1 = args.(0) in |