Skip to content

Instantly share code, notes, and snippets.

@ciao1092
Created October 19, 2023 15:37
Show Gist options
  • Save ciao1092/57e982336d27965cd31530214135be29 to your computer and use it in GitHub Desktop.
Save ciao1092/57e982336d27965cd31530214135be29 to your computer and use it in GitHub Desktop.
Windows script to generate a secret key (requires node to be present in path!)
@set "code=console.log(require('crypto'^).randomBytes(64^).toString('hex'^)^);"
:randomFileName
@set "tempFileName=%temp%\%random%%random%%random%.js"
@(@if exist "%tempFileName%" (@goto :randomFileName) else ((@echo %code%) > "%tempFileName%")) && (@node "%tempFileName%" | @clip) && (@del "%tempFileName%") && @exit /b 0
@ciao1092
Copy link
Author

ciao1092 commented Oct 19, 2023

It will generate a key and copy it to the clipboard.
Node needs to be installed and in the %PATH%.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment