Skip to content

Instantly share code, notes, and snippets.

@danwdart

danwdart/productkeys.js

Last active Jun 6, 2018
Embed
What would you like to do?
Easy product keys
// Small
> Math.round(Math.random() * Number.MAX_SAFE_INTEGER).toString(36).toUpperCase().match(/.{1,4}/g).join(`-`);
'2DSH-DWGM-7X5'
// Long, like Windows 98
> Array(5).fill().map(x => Array(5).fill().map(x => Math.floor(Math.random() * 36).toString(36)).join(``)).join(`-`).toUpperCase()
'1WH4O-WLUT5-DA1DJ-KNNCK-7A32I'
// No repeats for "fill"
> (a => a.map(x => a.map(x => Math.floor(Math.random() * 36).toString(36)).join(``)).join(`-`).toUpperCase())(Array(5).fill())
'07GK4-YNLZH-TK38I-PH7YL-FPQ1Q'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment