# Random string using NodeJS Crypto module

A simple use case is if: you need to generate a token for API authentication.
Simply open the Node REPL on your shell and type:

$ node 

Welcome to Node.js
Type ".help" for more information.
>

inside the REPL command line, write this line of code:

require('crypto').randomBytes(64).toString('hex')

you're done, the output is a random string like the one below

cba2e230ea425b61af9dbafa4d6088d3571a3e98fe90c5303584d8f7700205de50628470e7f143755e2c94caf57cdd2202518af5e2785e6e8321d84f5e0f2999

Fore more in depth info, read about crypto module, randomBytes() and toString() methods on the NodeJS site.