MCPcopy Create free account
hub / github.com/ampproject/amphtml / getRandomString64

Function getRandomString64

src/service/cid-impl.js:709–723  ·  view source on GitHub ↗
(win)

Source from the content-addressed store, hash-verified

707 * @return {!Promise<string>} The cid
708 */
709export function getRandomString64(win) {
710 const entropy = getEntropy(win);
711 if (typeof entropy == 'string') {
712 return Services.cryptoFor(win).sha384Base64(entropy);
713 } else {
714 // If our entropy is a pure random number, we can just directly turn it
715 // into base 64
716 const cast = /** @type {!Uint8Array} */ (entropy);
717 return tryResolve(() =>
718 base64UrlEncodeFromBytes(cast)
719 // Remove trailing padding
720 .replace(/\.+$/, '')
721 );
722 }
723}
724
725/**
726 * @param {!./ampdoc-impl.AmpDoc} ampdoc

Callers 3

pageViewId64Method · 0.90
constructorMethod · 0.90
getOrCreateCookieFunction · 0.85

Calls 5

tryResolveFunction · 0.90
base64UrlEncodeFromBytesFunction · 0.90
getEntropyFunction · 0.85
sha384Base64Method · 0.80
replaceMethod · 0.45

Tested by

no test coverage detected