Mercurial > hg > nginx-site
comparison xml/en/docs/njs/njs_api.xml @ 2177:79297494d291
Added njs Crypto API.
author | Yaroslav Zhuravlev <yar@nginx.com> |
---|---|
date | Tue, 05 Jun 2018 18:23:38 +0300 |
parents | 95b406f1f347 |
children | cb431c861670 |
comparison
equal
deleted
inserted
replaced
2176:95b406f1f347 | 2177:79297494d291 |
---|---|
93 </example> | 93 </example> |
94 </para> | 94 </para> |
95 | 95 |
96 </section> | 96 </section> |
97 | 97 |
98 | |
99 <section id="crypto" name="Crypto"> | |
100 | |
101 <para> | |
102 The Crypto module provides cryptographic functionality support. | |
103 The Crypto module object is returned by <literal>require('crypto')</literal>. | |
104 </para> | |
105 | |
106 <para> | |
107 <list type="tag"> | |
108 | |
109 <tag-name><literal>crypto.createHash(<value>algorithm</value>)</literal></tag-name> | |
110 <tag-desc> | |
111 Creates and returns a <link id="crypto_hash">Hash</link> object | |
112 that can be used to generate hash digests | |
113 using the given <value>algorithm</value>. | |
114 The algorighm can be | |
115 <literal>md5</literal>, | |
116 <literal>sha1</literal>, and | |
117 <literal>sha256</literal>. | |
118 </tag-desc> | |
119 | |
120 <tag-name><literal>crypto.createHmac(<value>algorithm</value>, | |
121 <value>secret key</value>)</literal></tag-name> | |
122 <tag-desc> | |
123 Creates and returns an <link id="crypto_hmac">HMAC</link> object | |
124 that uses the given <value>algorithm</value> and <value>secret key</value>. | |
125 The algorighm can be | |
126 <literal>md5</literal>, | |
127 <literal>sha1</literal>, and | |
128 <literal>sha256</literal>. | |
129 </tag-desc> | |
130 | |
131 </list> | |
132 </para> | |
133 | |
134 | |
135 <section id="crypto_hash" name="Hash"> | |
136 | |
137 <para> | |
138 <list type="tag"> | |
139 | |
140 <tag-name><literal>hash.update(<value>data</value>)</literal></tag-name> | |
141 <tag-desc> | |
142 Updates the hash content with the given <value>data</value>. | |
143 </tag-desc> | |
144 | |
145 <tag-name><literal>hash.digest([<value>encoding</value>])</literal></tag-name> | |
146 <tag-desc> | |
147 Calculates the digest of all of the data passed using | |
148 <literal>hash.update()</literal>. | |
149 The encoding can be | |
150 <literal>hex</literal>, | |
151 <literal>base64</literal>, and | |
152 <literal>base64url</literal>. | |
153 If encoding is not provided, a byte string is returned. | |
154 </tag-desc> | |
155 | |
156 </list> | |
157 </para> | |
158 | |
159 <para> | |
160 <example> | |
161 >> var cr = require('crypto') | |
162 undefined | |
163 | |
164 >> cr.createHash('sha1').update('A').update('B').digest('base64url') | |
165 BtlFlCqiamG-GMPiK_GbvKjdK10 | |
166 </example> | |
167 </para> | |
168 | |
169 </section> | |
170 | |
171 | |
172 <section id="crypto_hmac" name="HMAC"> | |
173 | |
174 <para> | |
175 <list type="tag"> | |
176 | |
177 <tag-name><literal>hmac.update(<value>data</value>)</literal></tag-name> | |
178 <tag-desc> | |
179 Updates the HMAC content with the given <value>data</value>. | |
180 </tag-desc> | |
181 | |
182 <tag-name><literal>hmac.digest([<value>encoding</value>])</literal></tag-name> | |
183 <tag-desc> | |
184 Calculates the HMAC digest of all of the data passed using | |
185 <literal>hmac.update()</literal>. | |
186 The encoding can be | |
187 <literal>hex</literal>, | |
188 <literal>base64</literal>, and | |
189 <literal>base64url</literal>. | |
190 If encoding is not provided, a byte string is returned. | |
191 </tag-desc> | |
192 </list> | |
193 </para> | |
194 | |
195 <para> | |
196 <example> | |
197 >> var cr = require('crypto') | |
198 undefined | |
199 | |
200 >> cr.createHmac('sha1', 'secret.key').update('AB').digest('base64url') | |
201 Oglm93xn23_MkiaEq_e9u8zk374 | |
202 </example> | |
203 </para> | |
204 | |
205 </section> | |
206 | |
207 </section> | |
208 | |
98 </section> | 209 </section> |
99 | 210 |
100 | 211 |
101 <section id="http" name="HTTP"> | 212 <section id="http" name="HTTP"> |
102 | 213 |