Commit 28115753 by PLN (Algolia)

scripts: drop the share-token generator — tokens are gone

Co-Authored-By: 's avatarClaude Opus 5 <noreply@anthropic.com>
parent 5eee5b5f
#!/usr/bin/env node
// Print a random 6-char share token for an unlisted draft link —
// paste it as `share:` in the post's frontmatter (node scripts/new-share-token.mjs).
const alphabet = 'abcdefghijklmnopqrstuvwxyz0123456789';
function pick(count) {
const max = 256 - (256 % alphabet.length); // rejection sampling: no modulo bias
const bytes = new Uint8Array(count);
let n = 0;
while (n < count) {
crypto.getRandomValues(bytes);
for (const byte of bytes) {
if (byte < max) {
process.stdout.write(alphabet[byte % alphabet.length]);
if (++n === count) return;
}
}
}
}
pick(6);
console.log();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment