Skip to content

Commit af09a9c

Browse files
committed
doc: fix crypto update() signatures
PR-URL: #5500 Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
1 parent 1cf26c0 commit af09a9c

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

doc/api/crypto.markdown

+25-10
Original file line numberDiff line numberDiff line change
@@ -669,10 +669,15 @@ provided a string is returned; otherwise a [`Buffer`][] is returned;
669669
The `Hmac` object can not be used again after `hmac.digest()` has been
670670
called. Multiple calls to `hmac.digest()` will result in an error being thrown.
671671

672-
### hmac.update(data)
672+
### hmac.update(data[, input_encoding])
673673

674-
Update the `Hmac` content with the given `data`. This can be called
675-
many times with new data as it is streamed.
674+
Updates the `Hmac` content with the given `data`, the encoding of which
675+
is given in `input_encoding` and can be `'utf8'`, `'ascii'` or
676+
`'binary'`. If `encoding` is not provided, and the `data` is a string, an
677+
encoding of `'utf8'` is enforced. If `data` is a [`Buffer`][] then
678+
`input_encoding` is ignored.
679+
680+
This can be called many times with new data as it is streamed.
676681

677682
## Class: Sign
678683

@@ -733,10 +738,15 @@ returned.
733738
The `Sign` object can not be again used after `sign.sign()` method has been
734739
called. Multiple calls to `sign.sign()` will result in an error being thrown.
735740

736-
### sign.update(data)
741+
### sign.update(data[, input_encoding])
742+
743+
Updates the `Sign` content with the given `data`, the encoding of which
744+
is given in `input_encoding` and can be `'utf8'`, `'ascii'` or
745+
`'binary'`. If `encoding` is not provided, and the `data` is a string, an
746+
encoding of `'utf8'` is enforced. If `data` is a [`Buffer`][] then
747+
`input_encoding` is ignored.
737748

738-
Updates the sign object with the given `data`. This can be called many times
739-
with new data as it is streamed.
749+
This can be called many times with new data as it is streamed.
740750

741751
## Class: Verify
742752

@@ -780,10 +790,15 @@ console.log(verify.verify(public_key, signature));
780790
// Prints true or false
781791
```
782792

783-
### verifier.update(data)
793+
### verifier.update(data[, input_encoding])
784794

785-
Updates the verifier object with the given `data`. This can be called many
786-
times with new data as it is streamed.
795+
Updates the `Verify` content with the given `data`, the encoding of which
796+
is given in `input_encoding` and can be `'utf8'`, `'ascii'` or
797+
`'binary'`. If `encoding` is not provided, and the `data` is a string, an
798+
encoding of `'utf8'` is enforced. If `data` is a [`Buffer`][] then
799+
`input_encoding` is ignored.
800+
801+
This can be called many times with new data as it is streamed.
787802

788803
### verifier.verify(object, signature[, signature_format])
789804

@@ -811,7 +826,7 @@ or [buffers][`Buffer`]. The default value is `'buffer'`, which makes methods
811826
default to [`Buffer`][] objects.
812827

813828
The `crypto.DEFAULT_ENCODING` mechanism is provided for backwards compatibility
814-
with legacy programs that expect `'utf8'` to be the default encoding.
829+
with legacy programs that expect `'binary'` to be the default encoding.
815830

816831
New applications should expect the default to be `'buffer'`. This property may
817832
become deprecated in a future Node.js release.

0 commit comments

Comments
 (0)