Skip to content

Instantly share code, notes, and snippets.

@tomarsachin2271
Created April 20, 2024 08:14
Show Gist options
  • Save tomarsachin2271/97f14878f847fd6d43d146333806ea57 to your computer and use it in GitHub Desktop.
Save tomarsachin2271/97f14878f847fd6d43d146333806ea57 to your computer and use it in GitHub Desktop.
Script to generate random API Keys
import * as shortid from "shortid";
import { v4 as uuidv4 } from "uuid";
const createApiKey = (apiKeyPrefix: string): string =>
`${apiKeyPrefix}.${uuidv4()}`;
function generateApiKey(): string {
const apiKeyPrefix = shortid.generate();
return createApiKey(apiKeyPrefix);
}
let apiKey = generateApiKey();
console.log(`Generated API Key: ${apiKey}`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment