MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / PublicKeyHash

Method PublicKeyHash

src/openrct2/network/NetworkKey.cpp:169–186  ·  view source on GitHub ↗

* @brief Key::PublicKeyHash * Computes a short, human-readable (e.g. asciif-ied hex) hash for a given * public key. Serves a purpose of easy identification keys in multiplayer * overview, multiplayer settings. * * In particular, any of digest functions applied to a standardised key * representation, like PEM, will be sufficient. * * @return returns a string

Source from the content-addressed store, hash-verified

167 * @return returns a string containing key hash.
168 */
169 std::string Key::PublicKeyHash()
170 {
171 try
172 {
173 std::string key = PublicKeyString();
174 if (key.empty())
175 {
176 throw std::runtime_error("No key found");
177 }
178 auto hash = Crypt::SHA1(key.c_str(), key.size());
179 return String::StringFromHex(hash);
180 }
181 catch (const std::exception& e)
182 {
183 LOG_ERROR("Failed to create hash of public key: %s", e.what());
184 }
185 return {};
186 }
187
188 bool Key::Sign(const uint8_t* md, const size_t len, std::vector<uint8_t>& signature) const
189 {

Callers 2

BeginClientMethod · 0.80
ServerHandleAuthMethod · 0.80

Calls 5

SHA1Function · 0.85
StringFromHexFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected