Skip to content

Commit

Permalink
doc: clarify documentation in crypto
Browse files Browse the repository at this point in the history
Clarify on the return values for crypto.publicEncrypt and similar
functions

Fixes: nodejs#12946
  • Loading branch information
jieyanhuang committed Oct 16, 2017
1 parent c81fd7c commit 29dbf82
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions doc/api/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -1687,12 +1687,15 @@ added: v0.11.14
`crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING`,
`RSA_PKCS1_PADDING`, or `crypto.constants.RSA_PKCS1_OAEP_PADDING`.
- `buffer` {Buffer | TypedArray | DataView}
- Returns: {Buffer}

Decrypts `buffer` with `privateKey`.

`privateKey` can be an object or a string. If `privateKey` is a string, it is
treated as the key with no passphrase and will use `RSA_PKCS1_OAEP_PADDING`.

Returns a new `Buffer` with the decrypted content.

### crypto.privateEncrypt(privateKey, buffer)
<!-- YAML
added: v1.1.0
Expand All @@ -1704,12 +1707,15 @@ added: v1.1.0
`crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING` or
`RSA_PKCS1_PADDING`.
- `buffer` {Buffer | TypedArray | DataView}
- Returns: {Buffer}

Encrypts `buffer` with `privateKey`.

`privateKey` can be an object or a string. If `privateKey` is a string, it is
treated as the key with no passphrase and will use `RSA_PKCS1_PADDING`.

Returns a new `Buffer` with the encrypted content.

### crypto.publicDecrypt(publicKey, buffer)
<!-- YAML
added: v1.1.0
Expand All @@ -1721,6 +1727,7 @@ added: v1.1.0
`crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING` or
`RSA_PKCS1_PADDING`.
- `buffer` {Buffer | TypedArray | DataView}
- Returns: {Buffer}

Decrypts `buffer` with `publicKey`.

Expand All @@ -1730,6 +1737,8 @@ treated as the key with no passphrase and will use `RSA_PKCS1_PADDING`.
Because RSA public keys can be derived from private keys, a private key may
be passed instead of a public key.

Returns a new `Buffer` with the decrypted content.

### crypto.publicEncrypt(publicKey, buffer)
<!-- YAML
added: v0.11.14
Expand All @@ -1741,6 +1750,7 @@ added: v0.11.14
`crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING`,
`RSA_PKCS1_PADDING`, or `crypto.constants.RSA_PKCS1_OAEP_PADDING`.
- `buffer` {Buffer | TypedArray | DataView}
- Returns: {Buffer}

Encrypts the content of `buffer` with `publicKey` and returns a new
[`Buffer`][] with encrypted content.
Expand All @@ -1751,6 +1761,8 @@ treated as the key with no passphrase and will use `RSA_PKCS1_OAEP_PADDING`.
Because RSA public keys can be derived from private keys, a private key may
be passed instead of a public key.

Returns a new `Buffer` with the encrypted content.

### crypto.randomBytes(size[, callback])
<!-- YAML
added: v0.5.8
Expand Down

0 comments on commit 29dbf82

Please sign in to comment.