From 82d716cf99b769a421a7126a581d22a2398cf329 Mon Sep 17 00:00:00 2001 From: xx Date: Thu, 13 Mar 2025 16:58:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0SHA256?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/module/codec.cpp | 8 ++++++-- src/module/codec.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/module/codec.cpp b/src/module/codec.cpp index 8b32cc5..f7ca109 100644 --- a/src/module/codec.cpp +++ b/src/module/codec.cpp @@ -46,7 +46,10 @@ std::string module::codec::sha1(const std::string_view& value) { return ylib::codec::sha1(ylib::buffer(value.data(), value.length())).to_hex(); } - +std::string module::codec::sha256(const std::string_view& value) +{ + return ylib::codec::sha256(ylib::buffer(value.data(), value.length())).to_hex(); +} void module::codec::regist(sol::state* lua) { lua->new_usertype("fw_codec", @@ -55,6 +58,7 @@ void module::codec::regist(sol::state* lua) "to_utf8", &module::codec::to_utf8, "to_gbk", &module::codec::to_gbk, "md5", &module::codec::md5, - "sha1", &module::codec::sha1 + "sha1", &module::codec::sha1, + "sha256", &module::codec::sha256, ); } diff --git a/src/module/codec.h b/src/module/codec.h index c5b916d..fb8c84d 100644 --- a/src/module/codec.h +++ b/src/module/codec.h @@ -31,6 +31,7 @@ namespace module static std::string md5(const std::string& value); static std::string sha1(const std::string_view& value); + static std::string sha256(const std::string_view& value); static void regist(sol::state* lua); };