(win)
| 707 | * @return {!Promise<string>} The cid |
| 708 | */ |
| 709 | export 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 |
no test coverage detected