![]() |
In this article, we are going to learn how to generate a unique ID using Node.js. Unique ID means a string contains a unique identity throughout the program. Table of Content PrerequisitesApproach 1: Using UUIDUUID is a module of NPM (Node Package Manager). UUID stands for Universally Unique Identifier. It is used to create a highly unique idenitifier that should not be duplicated easily, and it contains 32 hexadecimal characters that are grouped into five segments, which are separated by a hyphen.
npm i uuid Example : Implementation of above given UUID. Javascript
Output: Approach 2: Using CryptoCrypto is a library of Node.js; you don’t need to install it separately in your project. It provides cryptographic functionality to Node JS.It can be used for the following requirements:
Example: Implementation of above approach. Javascript
Output: |
Reffered: https://www.geeksforgeeks.org
Node.js |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |