Security: Improve the authorization of plugins

This commit is contained in:
yuanyuanxiang
2025-06-28 04:03:06 +08:00
parent 246fb01bf5
commit 2e1a5156e9
8 changed files with 57 additions and 6 deletions

View File

@@ -120,6 +120,14 @@ std::string hashSHA256(const std::string& data) {
return result.str();
}
std::string genHMAC(const std::string& pwdHash, const std::string& superPass) {
std::string key = hashSHA256(superPass);
std::vector<std::string> list({ "g","h","o","s","t" });
for (int i = 0; i < list.size(); ++i)
key = hashSHA256(key + " - " + list.at(i));
return hashSHA256(pwdHash + " - " + key).substr(0, 16);
}
// <20><><EFBFBD><EFBFBD> 16 <20>ַ<EFBFBD><D6B7><EFBFBD>Ψһ<CEA8>豸 ID
std::string getFixedLengthID(const std::string& hash) {
return hash.substr(0, 4) + "-" + hash.substr(4, 4) + "-" + hash.substr(8, 4) + "-" + hash.substr(12, 4);