# 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 (opens new window), randomBytes() (opens new window) and toString() (opens new window) methods on the NodeJS (opens new window) site.