Skip to main content

Posts

Showing posts with the label crypto

Web Crypto API - Node 16

  Experimental Web Crypto API The Web Crypto API is the newer more well defined version of the Crypto library for JavaScript. All of the new Web Crypto methods are available on the  subtle  interface. Many browsers used an interface called  Crypto  without having a specific specification. The Web Crypto API adds a standard to the  Crypto  library. import { webcrypto } from 'crypto' ; const { subtle } = webcrypto ; ( async function ( ) { const key = await subtle . generateKey ( { name : 'HMAC' , hash : 'SHA-256' , length : 256 } , true , [ 'sign' , 'verify' ] ) ; const digest = await subtle . sign ( { name : 'HMAC' } , key , 'I love node.js' ) ; console . log ( digest ) ; } ) ( ) ;