Skip to content

Commit 5c5d881

Browse files
addaleaxtargos
authored andcommitted
doc: improve asymmetric crypto docs
Refs: #22792 PR-URL: #22820 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 790864b commit 5c5d881

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

doc/api/crypto.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -1912,7 +1912,8 @@ added: v0.11.14
19121912
* `buffer` {Buffer | TypedArray | DataView}
19131913
* Returns: {Buffer} A new `Buffer` with the decrypted content.
19141914

1915-
Decrypts `buffer` with `privateKey`.
1915+
Decrypts `buffer` with `privateKey`. `buffer` was previously encrypted using
1916+
the corresponding public key, for example using [`crypto.publicEncrypt()`][].
19161917

19171918
`privateKey` can be an object or a string. If `privateKey` is a string, it is
19181919
treated as the key with no passphrase and will use `RSA_PKCS1_OAEP_PADDING`.
@@ -1930,7 +1931,8 @@ added: v1.1.0
19301931
* `buffer` {Buffer | TypedArray | DataView}
19311932
* Returns: {Buffer} A new `Buffer` with the encrypted content.
19321933

1933-
Encrypts `buffer` with `privateKey`.
1934+
Encrypts `buffer` with `privateKey`. The returned data can be decrypted using
1935+
the corresponding public key, for example using [`crypto.publicDecrypt()`][].
19341936

19351937
`privateKey` can be an object or a string. If `privateKey` is a string, it is
19361938
treated as the key with no passphrase and will use `RSA_PKCS1_PADDING`.
@@ -1948,7 +1950,8 @@ added: v1.1.0
19481950
* `buffer` {Buffer | TypedArray | DataView}
19491951
* Returns: {Buffer} A new `Buffer` with the decrypted content.
19501952

1951-
Decrypts `buffer` with `key`.
1953+
Decrypts `buffer` with `key`.`buffer` was previously encrypted using
1954+
the corresponding private key, for example using [`crypto.privateEncrypt()`][].
19521955

19531956
`key` can be an object or a string. If `key` is a string, it is treated as
19541957
the key with no passphrase and will use `RSA_PKCS1_PADDING`.
@@ -1971,7 +1974,8 @@ added: v0.11.14
19711974
* Returns: {Buffer} A new `Buffer` with the encrypted content.
19721975

19731976
Encrypts the content of `buffer` with `key` and returns a new
1974-
[`Buffer`][] with encrypted content.
1977+
[`Buffer`][] with encrypted content. The returned data can be decrypted using
1978+
the corresponding private key, for example using [`crypto.privateDecrypt()`][].
19751979

19761980
`key` can be an object or a string. If `key` is a string, it is treated as
19771981
the key with no passphrase and will use `RSA_PKCS1_OAEP_PADDING`.
@@ -2765,6 +2769,10 @@ the `crypto`, `tls`, and `https` modules and are generally specific to OpenSSL.
27652769
[`crypto.createVerify()`]: #crypto_crypto_createverify_algorithm_options
27662770
[`crypto.getCurves()`]: #crypto_crypto_getcurves
27672771
[`crypto.getHashes()`]: #crypto_crypto_gethashes
2772+
[`crypto.privateDecrypt()`]: #crypto_crypto_privatedecrypt_privatekey_buffer
2773+
[`crypto.privateEncrypt()`]: #crypto_crypto_privateencrypt_privatekey_buffer
2774+
[`crypto.publicDecrypt()`]: #crypto_crypto_publicdecrypt_key_buffer
2775+
[`crypto.publicEncrypt()`]: #crypto_crypto_publicencrypt_key_buffer
27682776
[`crypto.randomBytes()`]: #crypto_crypto_randombytes_size_callback
27692777
[`crypto.randomFill()`]: #crypto_crypto_randomfill_buffer_offset_size_callback
27702778
[`crypto.scrypt()`]: #crypto_crypto_scrypt_password_salt_keylen_options_callback

0 commit comments

Comments
 (0)