{"_id":"@bturkis/keygen","name":"@bturkis/keygen","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@bturkis/keygen","version":"1.0.0","type":"module","description":"Cryptographically secure key generators — hex keys, UUIDs, passwords, random strings, and text-to-key hashing. Uses Web Crypto API.","author":{"name":"bturkis"},"license":"MIT","homepage":"https://keygen.neisterse.com","keywords":["keygen","key-generator","password-generator","uuid","hex-key","secret-key","random-string","crypto","security","web-crypto-api","cryptography","token","hash"],"main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"sideEffects":false,"engines":{"node":">=18.0.0"},"scripts":{"build":"nuxt build","dev":"nuxt dev","generate":"nuxt generate","preview":"nuxt preview","postinstall":"nuxt prepare","start":"PORT=4002 node -r dotenv/config .output/server/index.mjs","db:generate":"drizzle-kit generate","db:push":"drizzle-kit push","db:studio":"drizzle-kit studio","db:seed":"npx tsx server/db/seed.ts","lib:build":"tsup","lib:watch":"tsup --watch","prepublishOnly":"tsup"},"dependencies":{"drizzle-orm":"^0.45.1","lucide-vue-next":"^0.563.0","nuxt":"^4.2.2","pg":"^8.18.0","qrcode":"^1.5.4","sass":"^1.97.1","uuid":"^13.0.0","vue":"^3.5.26","vue-router":"^4.6.4"},"devDependencies":{"@nuxtjs/robots":"^5.7.0","@nuxtjs/sitemap":"^7.6.0","@types/pg":"^8.16.0","@types/qrcode":"^1.5.6","@types/uuid":"^10.0.0","dotenv":"^17.2.3","drizzle-kit":"^0.31.8","tsup":"^8.5.1","tsx":"^4.21.0","typescript":"^5.9.3"},"gitHead":"43c45d3714670b443183956ff6353ba635d73398","_id":"@bturkis/keygen@1.0.0","_nodeVersion":"25.6.1","_npmVersion":"11.9.0","dist":{"integrity":"sha512-y+ygoYjQgDErvW827uu7IsNgnpgHKGAsmrjGjVUtjPdHSQ3Kp8/3NILd9ILF5i4CsnUxdEBiTVZFn/wfWZy96A==","shasum":"de3e6db8e98e400b1899409bbfc89c60748b357a","tarball":"https://registry.npmjs.org/@bturkis/keygen/-/keygen-1.0.0.tgz","fileCount":9,"unpackedSize":85630,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBVtg/vYO3YlYgwyUUOWhNqNTc6/fXlCw1dcGWzJs3hwAiA34aX8s6h1ft6j5PNTFLOROzaPtitmRfuR1Mydh/8aOg=="}]},"_npmUser":{"name":"bturkis","email":"ugur@burakturkis.com"},"directories":{},"maintainers":[{"name":"bturkis","email":"ugur@burakturkis.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/keygen_1.0.0_1771916650671_0.9787200861926444"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-24T07:04:10.579Z","1.0.0":"2026-02-24T07:04:10.810Z","modified":"2026-02-24T07:04:11.026Z"},"maintainers":[{"name":"bturkis","email":"ugur@burakturkis.com"}],"description":"Cryptographically secure key generators — hex keys, UUIDs, passwords, random strings, and text-to-key hashing. Uses Web Crypto API.","homepage":"https://keygen.neisterse.com","keywords":["keygen","key-generator","password-generator","uuid","hex-key","secret-key","random-string","crypto","security","web-crypto-api","cryptography","token","hash"],"author":{"name":"bturkis"},"license":"MIT","readme":"# @bturkis/keygen\n\nCryptographically secure key generators for Node.js, Deno, and browsers.  \nAll generators use **Web Crypto API** (`crypto.getRandomValues`) — no `Math.random()`.\n\n[![npm version](https://img.shields.io/npm/v/@bturkis/keygen.svg)](https://www.npmjs.com/package/@bturkis/keygen)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n🌐 **Website:** [keygen.neisterse.com](https://keygen.neisterse.com)\n\n## Install\n\n```bash\nnpm install @bturkis/keygen\n# or\npnpm add @bturkis/keygen\n# or\nyarn add @bturkis/keygen\n```\n\n## Quick Start\n\n```ts\nimport {\n  generateHexKey,\n  generateUUID,\n  generatePassword,\n  generateSecretKey,\n  generateRandomString,\n  textToKey,\n} from \"@bturkis/keygen\";\n\n// Hex key (256-bit)\nconst hexKey = generateHexKey();\n// => [\"a1b2c3d4e5f6...\"]\n\n// UUID v4\nconst uuid = generateUUID();\n// => [\"550e8400-e29b-41d4-a716-446655440000\"]\n\n// Secure password\nconst password = generatePassword({ length: 16 });\n// => [\"xK9@mP2#qR5&wT8!\"]\n\n// Secret key (mixed chars)\nconst secret = generateSecretKey({ length: 64 });\n// => [\"x!K9@mP2#qR5&wT8...\"]\n\n// Random alphanumeric string\nconst token = generateRandomString({ length: 24 });\n// => [\"Abc123Xyz456DefGHij789Klm\"]\n\n// Text to SHA-256 hash\nconst hash = await textToKey(\"hello world\");\n// => \"b94d27b9934d3e08...\"\n```\n\n## API Reference\n\n### `generateHexKey(options?)`\n\nGenerate cryptographically secure hex keys.\n\n| Option              | Type      | Default | Description                |\n| ------------------- | --------- | ------- | -------------------------- |\n| `bytes`             | `number`  | `32`    | Number of random bytes     |\n| `count`             | `number`  | `1`     | Number of keys to generate |\n| `prefix`            | `string`  | `\"\"`    | Prepend to each key        |\n| `suffix`            | `string`  | `\"\"`    | Append to each key         |\n| `separator`         | `string`  | `\"\"`    | Between hex segments       |\n| `separatorInterval` | `number`  | `0`     | Chars between separators   |\n| `uppercase`         | `boolean` | `false` | Uppercase hex output       |\n\n```ts\n// API key with prefix\ngenerateHexKey({ bytes: 32, prefix: \"sk_live_\" });\n\n// MAC address style\ngenerateHexKey({\n  bytes: 6,\n  separator: \":\",\n  separatorInterval: 2,\n  uppercase: true,\n});\n// => [\"A1:B2:C3:D4:E5:F6\"]\n```\n\n### `generateUUID(options?)`\n\nGenerate RFC 4122 compliant UUID v4 identifiers.\n\n| Option  | Type     | Default | Description     |\n| ------- | -------- | ------- | --------------- |\n| `count` | `number` | `1`     | Number of UUIDs |\n\n### `generatePassword(options?)`\n\nGenerate secure passwords. Quotes (`'` and `\"`) excluded by default for shell/SQL safety.\n\n| Option          | Type      | Default | Description              |\n| --------------- | --------- | ------- | ------------------------ |\n| `length`        | `number`  | `16`    | Password length          |\n| `count`         | `number`  | `1`     | Number of passwords      |\n| `uppercase`     | `boolean` | `true`  | Include A-Z              |\n| `lowercase`     | `boolean` | `true`  | Include a-z              |\n| `numbers`       | `boolean` | `true`  | Include 0-9              |\n| `symbols`       | `boolean` | `true`  | Include special chars    |\n| `customSymbols` | `string`  | —       | Override default symbols |\n\n```ts\n// Simple password\ngeneratePassword({ length: 8, symbols: false });\n\n// Custom symbols only\ngeneratePassword({ customSymbols: \"!@#$\", length: 20 });\n```\n\n### `generateSecretKey(options?)`\n\nHigh-entropy keys with letters, digits, and special characters.\n\n| Option   | Type     | Default | Description    |\n| -------- | -------- | ------- | -------------- |\n| `length` | `number` | `32`    | Key length     |\n| `count`  | `number` | `1`     | Number of keys |\n\n### `generateRandomString(options?)`\n\nAlphanumeric strings (A-Z, a-z, 0-9). Safe for URLs, filenames, and databases.\n\n| Option   | Type     | Default | Description       |\n| -------- | -------- | ------- | ----------------- |\n| `length` | `number` | `16`    | String length     |\n| `count`  | `number` | `1`     | Number of strings |\n\n### `textToKey(text, options?)`\n\nConvert text to a deterministic hash. Returns a `Promise<string>`.\n\n| Option      | Type     | Default     | Description                              |\n| ----------- | -------- | ----------- | ---------------------------------------- |\n| `algorithm` | `string` | `\"SHA-256\"` | `SHA-1`, `SHA-256`, `SHA-384`, `SHA-512` |\n\n### `calculateEntropy(params)`\n\nCalculate entropy information for a key configuration.\n\n```ts\nimport { calculateEntropy } from \"@bturkis/keygen\";\n\ncalculateEntropy({ bytes: 32 });\n// => { bits: 256, strength: \"very-strong\", label: \"Very Strong - Maximum security\" }\n\ncalculateEntropy({ charPool: 92, length: 16 });\n// => { bits: 104, strength: \"fair\", label: \"Fair - Acceptable for basic security\" }\n```\n\n## Security\n\n- ✅ Uses `crypto.getRandomValues()` (Web Crypto API)\n- ✅ No `Math.random()` — cryptographically secure\n- ✅ Works in Node.js 18+, Deno, and modern browsers\n- ✅ Zero runtime dependencies (except `uuid` for UUID v4)\n- ✅ Tree-shakeable ESM + CJS builds\n\n## License\n\nMIT © [bturkis](https://keygen.neisterse.com)\n","readmeFilename":"README.md","_rev":"1-a980f70a5e957d682c69bc823eefd666"}