MCPcopy Create free account
hub / github.com/adobe/Marinus / createAPIKey

Function createAPIKey

web_server/routes/admin.js:40–44  ·  view source on GitHub ↗

* Generates a random string of hex characters that is len characters long. * It will have the security of a len/2 password * * @param {Number} len The length of the API key to generate. * @return {String} A string representing len # of random bytes.

(len)

Source from the content-addressed store, hash-verified

38 * @return {String} A string representing len # of random bytes.
39 */
40function createAPIKey(len) {
41 return crypto.randomBytes(Math.ceil(len / 2))
42 .toString('hex') // convert to hexadecimal format
43 .slice(0, len); // return required number of characters
44}
45
46/**
47 * Validates the user identified in the request session is an admin.

Callers 1

adminRouterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected