# HG changeset patch # User Yaroslav Zhuravlev # Date 1528212218 -10800 # Node ID 79297494d291dbaa7d5c122eb49880a49af07ecb # Parent 95b406f1f347257c108b3c7ab4ed75dcef67ec90 Added njs Crypto API. diff -r 95b406f1f347 -r 79297494d291 xml/en/docs/njs/njs_api.xml --- a/xml/en/docs/njs/njs_api.xml Tue Jun 05 18:23:19 2018 +0300 +++ b/xml/en/docs/njs/njs_api.xml Tue Jun 05 18:23:38 2018 +0300 @@ -95,6 +95,117 @@ + +
+ + +The Crypto module provides cryptographic functionality support. +The Crypto module object is returned by require('crypto'). + + + + + +crypto.createHash(algorithm) + +Creates and returns a Hash object +that can be used to generate hash digests +using the given algorithm. +The algorighm can be +md5, +sha1, and +sha256. + + +crypto.createHmac(algorithm, +secret key) + +Creates and returns an HMAC object +that uses the given algorithm and secret key. +The algorighm can be +md5, +sha1, and +sha256. + + + + + + +
+ + + + +hash.update(data) + +Updates the hash content with the given data. + + +hash.digest([encoding]) + +Calculates the digest of all of the data passed using +hash.update(). +The encoding can be +hex, +base64, and +base64url. +If encoding is not provided, a byte string is returned. + + + + + + + +>> var cr = require('crypto') +undefined + +>> cr.createHash('sha1').update('A').update('B').digest('base64url') +BtlFlCqiamG-GMPiK_GbvKjdK10 + + + +
+ + +
+ + + + +hmac.update(data) + +Updates the HMAC content with the given data. + + +hmac.digest([encoding]) + +Calculates the HMAC digest of all of the data passed using +hmac.update(). +The encoding can be +hex, +base64, and +base64url. +If encoding is not provided, a byte string is returned. + + + + + + +>> var cr = require('crypto') +undefined + +>> cr.createHmac('sha1', 'secret.key').update('AB').digest('base64url') +Oglm93xn23_MkiaEq_e9u8zk374 + + + +
+ +
+