Fix a md5 sum bug without openssl (#951)

This commit is contained in:
putao520 2021-07-25 23:16:13 +08:00 committed by GitHub
parent 1c04b1a419
commit 64f9f8b87f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -51,7 +51,7 @@ uint32_t Md5Encode::fillData(const char *inDataPtr,
// int grop_num = bitNum / BIT_OF_GROUP; // int grop_num = bitNum / BIT_OF_GROUP;
int modBitNum = bitNum % BIT_OF_GROUP; int modBitNum = bitNum % BIT_OF_GROUP;
int bitNeedFill = 0; int bitNeedFill = 0;
if (modBitNum > (BIT_OF_GROUP - SRC_DATA_LEN)) if (modBitNum >= (BIT_OF_GROUP - SRC_DATA_LEN))
{ {
bitNeedFill = (BIT_OF_GROUP - modBitNum); bitNeedFill = (BIT_OF_GROUP - modBitNum);
bitNeedFill += (BIT_OF_GROUP - SRC_DATA_LEN); bitNeedFill += (BIT_OF_GROUP - SRC_DATA_LEN);

View File

@ -9,4 +9,8 @@ DROGON_TEST(Md5Test)
"1234567890") == "1234567890") ==
"49CB3608E2B33FAD6B65DF8CB8F49668"); "49CB3608E2B33FAD6B65DF8CB8F49668");
CHECK(drogon::utils::getMd5("1") == "C4CA4238A0B923820DCC509A6F75849B"); CHECK(drogon::utils::getMd5("1") == "C4CA4238A0B923820DCC509A6F75849B");
CHECK(drogon::utils::getMd5("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF") ==
"59F761506DFA597B0FAF1968F7CCA867");
} }