
- Node.js - Home
- Node.js - Introduction
- Node.js - Environment Setup
- Node.js - First Application
- Node.js - REPL Terminal
- Node.js - Command Line Options
- Node.js - Package Manager (NPM)
- Node.js - Callbacks Concept
- Node.js - Upload Files
- Node.js - Send an Email
- Node.js - Events
- Node.js - Event Loop
- Node.js - Event Emitter
- Node.js - Debugger
- Node.js - Global Objects
- Node.js - Console
- Node.js - Process
- Node.js - Scaling Application
- Node.js - Packaging
- Node.js - Express Framework
- Node.js - RESTFul API
- Node.js - Buffers
- Node.js - Streams
- Node.js - File System
- Node.js MySQL
- Node.js - MySQL Get Started
- Node.js - MySQL Create Database
- Node.js - MySQL Create Table
- Node.js - MySQL Insert Into
- Node.js - MySQL Select From
- Node.js - MySQL Where
- Node.js - MySQL Order By
- Node.js - MySQL Delete
- Node.js - MySQL Update
- Node.js - MySQL Join
- Node.js MongoDB
- Node.js - MongoDB Get Started
- Node.js - MongoDB Create Database
- Node.js - MongoDB Create Collection
- Node.js - MongoDB Insert
- Node.js - MongoDB Find
- Node.js - MongoDB Query
- Node.js - MongoDB Sort
- Node.js - MongoDB Delete
- Node.js - MongoDB Update
- Node.js - MongoDB Limit
- Node.js - MongoDB Join
- Node.js Modules
- Node.js - Modules
- Node.js - Built-in Modules
- Node.js - Utility Modules
- Node.js - Web Module
Node.js - Crypto
In Node.js, crypto is a in-built module that provides cryptographic functionalities that are essential for incorporating security aspects into a project, for instance, encryption, decryption, hash functions, and more. This module rely on OpenSSL for its cryptographic operations.
Cryptography is the process of putting data into a form that can only be understood by users who meet certain predetermined conditions.
Cryptography is not only about encoding and decoding the messages, It is about making sure that information remains private, integral, and genuine in the growing globalized context.
Crypto Class
The Crypto Class represents a basic cryptography features available in the current context. It is the built-in library of Node.js includes the Crypto module.
Property
Following is the property of crypto class −
Sr.No. | Property & Description |
---|---|
1 |
This property returns the SubtleCrypto interface. |
Methods
Following are the methods of Crypto class −
Sr.No. | Method & Description |
---|---|
1 |
crypto.getRandomValues(typedArray) The same array is passed as typedarray, but its contents are replaced with new random numbers in that place. |
2 |
This method returns a string containing a randomly generated. |
CryptoKey Class
A crypto-key class is used to represent a blueprint for creating and managing cryptographic keys.
Properties
Following is a list of properties available with the CryptoKey class −
Sr.No. | Properties & Description |
---|---|
1 |
cryptoKey.algorithm The object returned depends of the algorithm used to generate the key. |
2 |
cryptoKey.extractable A boolean value that is true if the key can be exported and false if not. |
3 |
cryptoKey.type It returns the array of strings which is in secret, private, or public. |
4 |
cryptoKey.usages It returns the array of strings from the list. |
CryptoKeyPair Class
The CryptoKeyPair class provides a structured way to manage and utilize public and private key pairs.
Properties
Following is a list of properties of the CryptoKeyPair class −
Sr.No. | Properties & Description |
---|---|
1 |
cryptoKeyPair.privateKey This property provides access to the private key of the key pair. |
2 |
cryptoKeyPair.publicKey This property provides access to the public key of the key pair. |
SubtleCrypto Class
The SubtleCrypto class is a part of the Web Cryptography API, designed to perform low-level cryptographic operations in web applications. It provides methods for generating keys.
Methods
Following are the list of methods to the SubtleCrypto class −
Sr.No. | Methods & Description |
---|---|
1 |
subtle.decrypt(algorithm, key, data) It returns a Promise that resolves with the decrypted data as an ArrayBuffer. |
2 |
subtle.deriveBits(algorithm, baseKey, length) It returns a Promise that resolves with the derived bits as an ArrayBuffer. |
3 |
subtle.deriveKey(algorithm, baseKey, derivedKeyAlgorithm, extractable, keyUsages) It returns a Promise that resolves with a CryptoKey object. |
4 |
subtle.digest(algorithm, data) It returns a Promise that resolves with the digest of the given data as an ArrayBuffer. |
5 |
subtle.encrypt(algorithm, key, data) It returns a Promise that resolves with the encrypted data as an ArrayBuffer. |
6 |
subtle.exportKey(format, key) It returns a Promise that resolves with key data in the specified format. |
7 |
subtle.generateKey(algorithm, extractable, keyUsages) It returns a Promise that resolves with a newly generated CryptoKey object representing the generated key. |
8 |
subtle.importKey(format, keyData, algorithm, extractable, keyUsages) It returns a Promise that resolves with a CryptoKey object representing the imported key. |
9 |
subtle.sign(algorithm, key, data) It returns a Promise that resolves with the signature of the given data as an ArrayBuffer. |
10 |
subtle.unwrapKey(format, wrappedKey, unwrappingKey, unwrapAlgo, unwrappedKeyAlgo, extractable, keyUsages) It returns a Promise that resolves with a CryptoKey object representing the unwrapped key. |
11 |
subtle.verify(algorithm, key, signature, data) It returns a Promise that resolves with a boolean value indicating whether the signature provided matches the expected signature for the given data. |
12 |
subtle.wrapKey(format, key, wrappingKey, wrapAlgo) It returns a Promise that resolves with an ArrayBuffer or TypedArray containing the wrapped key data. |