# 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:


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


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