Node.js crypto.webcrypto Property
The crypto.webcrypto is an inbuilt application programming interface of class Crypto within crypto module which is used to get the object of crypto of Web Crypto API standard.
Syntax:
const crypto.webcrypto
Parameters: This property accepts nothing as parameter.
Return Value: This property returns the object of crypto of Web Crypto API standard.
Example 1:
index.js
const crypto = require( 'crypto' )
const val = crypto.webcrypto
const buffer = new ArrayBuffer(8)
console.log(val.getRandomValues(Int16Array.of(buffer)))
|
Run the index.js file using the following command.
node index.js
Output:
Int16Array(1) [ 31796 ]
Example 2:
index.js
console.log((require( 'crypto' ).webcrypto)
.getRandomValues(Int16Array.of( new ArrayBuffer(8))))
|
Run the index.js file using the following command.
node index.js
Output:
Int16Array(1) [ -6968 ]
Reference: https://nodejs.org/dist/latest-v15.x/docs/api/crypto.html#crypto_crypto_webcrypto
Last Updated :
05 Apr, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...