MCPcopy Create free account
hub / github.com/arun11299/cpp-jwt / str_to_alg

Function str_to_alg

include/jwt/algorithm.hpp:250–268  ·  view source on GitHub ↗

* Convert stringified algorithm to enum class. * The string comparison is case insesitive. */

Source from the content-addressed store, hash-verified

248 * The string comparison is case insesitive.
249 */
250inline SCOPED_ENUM algorithm str_to_alg(const jwt::string_view alg) noexcept
251{
252 if (!alg.length()) return algorithm::UNKN;
253
254 if (!strcasecmp(alg.data(), "NONE")) return algorithm::NONE;
255 if (!strcasecmp(alg.data(), "HS256")) return algorithm::HS256;
256 if (!strcasecmp(alg.data(), "HS384")) return algorithm::HS384;
257 if (!strcasecmp(alg.data(), "HS512")) return algorithm::HS512;
258 if (!strcasecmp(alg.data(), "RS256")) return algorithm::RS256;
259 if (!strcasecmp(alg.data(), "RS384")) return algorithm::RS384;
260 if (!strcasecmp(alg.data(), "RS512")) return algorithm::RS512;
261 if (!strcasecmp(alg.data(), "ES256")) return algorithm::ES256;
262 if (!strcasecmp(alg.data(), "ES384")) return algorithm::ES384;
263 if (!strcasecmp(alg.data(), "ES512")) return algorithm::ES512;
264
265 return algorithm::UNKN;
266
267 JWT_NOT_REACHED("Code not reached");
268}
269
270/**
271 */

Callers 2

algoMethod · 0.85
algorithm_paramMethod · 0.85

Calls 2

lengthMethod · 0.80
dataMethod · 0.80

Tested by

no test coverage detected