簡體   English   中英

這個 md5 實現有缺陷嗎?

[英]is there a flaw in this md5 implementation?

我一直在研究需要 md5 計算的 bacula 雲支持問題,並且一直在嘗試使用https://github.com/firebladed/bacula/blob/Branch-11.0/bacula/src/lib/md5.c並且我得到來自亞馬遜 s3 的錯誤 md5 錯誤

所以我嘗試將代碼直接編譯成 md5sum 可執行文件( Makefile

我得到了與 ubuntu md5sum 不同的 md5s

md5sum (GNU coreutils) 8.28
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Ulrich Drepper, Scott Miller and David Madore.

得到錯誤 md5 的示例文件

2521308b3fe3836623f78708a5c988d6 - ubuntu md5sum

e972192662d26a25af5fb895cf79b175 - 編譯的 md5sum

正在使用簡單的命令行進行測試

./md5sum <file>

對於已編譯的 md5sum

md5sum <file>

對於系統 md5sum

使用鏈接的例子

理想情況下,如果它的一些簡單的 id 喜歡修復它

您的輸入文件包含0x00字節,而程序使用while(fgets(buf, ...)) } { MD5Update(..., strlen(buf)) } strlen報告的大小小於“行”長度(您的輸入文件似乎是二進制文件),因此生成的 md5sum 是一組不同的字節。

將您的輸入數據轉換為文本( cat -v part.1 ),然后傳遞給兩個程序,或者使用for (int c; (c = fgetc(file)) != EOF; ) MD5Update(&ctx. &c, 1)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM