From f7c7ed0c60b97c4692da8758b211234fdc991113 Mon Sep 17 00:00:00 2001 From: YuHuanTin Date: Sun, 13 Apr 2025 17:46:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20md5=20=E5=8A=A0=E5=AF=86?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/misc/sign/APP.md | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/docs/misc/sign/APP.md b/docs/misc/sign/APP.md index b1dc9e8..2bd1e48 100644 --- a/docs/misc/sign/APP.md +++ b/docs/misc/sign/APP.md @@ -218,15 +218,15 @@ print(signResult) ### CplusPlus -需要 c++ 23 标准库,[cpr](https://github.com/libcpr/cpr)、[cryptopp](https://github.com/weidai11/cryptopp)、[nlohmann/json](https://github.com/nlohmann/json) 等依赖 +需要 c++ 23 标准库,[cpr](https://github.com/libcpr/cpr)、[botan](https://github.com/randombit/botan)、[nlohmann/json](https://github.com/nlohmann/json) 等依赖 ```c++ #include // std::println /// thrid party libraries +#include +#include #include // cpr::util::urlEncode() -#include -#include #include /* @@ -235,19 +235,9 @@ print(signResult) /* 获取 md5 hex(lower) */ std::string Get_md5_hex(const std::string &Input_str) { - CryptoPP::Weak1::MD5 hash; - std::string md5_hex; - - CryptoPP::StringSource ss(Input_str, true, - new CryptoPP::HashFilter(hash, - new CryptoPP::HexEncoder( - new CryptoPP::StringSink(md5_hex) - ) - ) - ); - - std::ranges::for_each(md5_hex, [](char &x) { x = std::tolower(x); }); - return md5_hex; + const auto md5 = Botan::HashFunction::create_or_throw("MD5"); + md5->update(Input_str); + return Botan::hex_encode(md5->final(), false); } /* 将 json 转换为 url 编码字符串 */