增加hmac_sha256

This commit is contained in:
xx
2025-03-13 17:16:06 +08:00
parent 2cae5d4370
commit 38abf34d41
2 changed files with 7 additions and 1 deletions

View File

@@ -50,6 +50,10 @@ std::string module::codec::sha256(const std::string_view& value)
{
return ylib::codec::sha256(ylib::buffer(value.data(), value.length())).to_hex();
}
std::string module::codec::hmac_sha256(const std::string& key, const std::string_view& value)
{
return ylib::codec::hmac_sha256(key,ylib::buffer(value.data(), value.length())).to_hex();
}
void module::codec::regist(sol::state* lua)
{
lua->new_usertype<module::codec>("fw_codec",
@@ -59,6 +63,7 @@ void module::codec::regist(sol::state* lua)
"to_gbk", &module::codec::to_gbk,
"md5", &module::codec::md5,
"sha1", &module::codec::sha1,
"sha256", &module::codec::sha256
"sha256", &module::codec::sha256,
"hmac_sha256", &module::codec::hmac_sha256
);
}

View File

@@ -32,6 +32,7 @@ namespace module
static std::string sha1(const std::string_view& value);
static std::string sha256(const std::string_view& value);
static std::string hmac_sha256(const std::string& key,const std::string_view& value);
static void regist(sol::state* lua);
};