The signature module contains a small set of basic utilities for generating and verifying signatures.
- Source:
Methods
(static) sign(privateKey, algorithm, message, inputEncoding, outputEncoding) → {string|Buffer}
Generate signatures for a message using a private key.
- Since:
- 0.1.0
- Source:
Parameters:
Name | Type | Description |
---|---|---|
privateKey |
Object
|
string
|
Buffer
|
KeyObject
|
The private key to be used for signing the message. |
algorithm |
string
|
The hashing algorithm to be used. |
message |
Data
|
The message to be signed. |
inputEncoding |
string
|
The encoding of the |
outputEncoding |
string
|
The encoding of the output signature. If provided a |
Returns:
- Type:
-
string
|Buffer
The generated signature for the provided message.
(async, static) signStream(privateKey, algorithm, input, inputEncoding, outputEncoding) → {Promise.<(string|Buffer)>}
Generate signatures for a message encapsulated in a stream using a private key.
- Since:
- 0.1.0
- Source:
Parameters:
Name | Type | Description |
---|---|---|
privateKey |
Object
|
string
|
Buffer
|
KeyObject
|
The private key to be used for signing the message. |
algorithm |
string
|
The hashing algorithm to be used. |
input |
ReadableStream.<Data>
|
The input stream containing the message to be signed. |
inputEncoding |
string
|
The encoding of the |
outputEncoding |
string
|
The encoding of the output signature. If provided a |
Returns:
- Type:
-
Promise.<(string|Buffer)>
The generated signature for the provided message.
(static) verify(publicKey, algorithm, message, signature, inputEncoding, signatureEncoding) → {boolean}
Verify if a signature is valid for a given message using the corresponding public key.
- Since:
- 0.1.0
- Source:
Parameters:
Name | Type | Description |
---|---|---|
publicKey |
Object
|
string
|
Buffer
|
KeyObject
|
The public key to be used for verifying the signature. |
algorithm |
string
|
The hashing algorithm to be used. |
message |
Data
|
The message for which the signature has been generated. |
signature |
string
|
Buffer
|
The signature to be verified. |
inputEncoding |
string
|
The encoding of the |
signatureEncoding |
string
|
The encoding of the provided |
Returns:
- Type:
-
boolean
Wether the signature was valid or not.
(async, static) verifyStream(publicKey, algorithm, input, signature, inputEncoding, signatureEncoding) → {Promise.<boolean>}
Verify if a signature is valid for a given message encapsulated in a stream using the corresponding public key.
- Since:
- 0.1.0
- Source:
Parameters:
Name | Type | Description |
---|---|---|
publicKey |
Object
|
string
|
Buffer
|
KeyObject
|
The public key to be used for verifying the signature. |
algorithm |
string
|
The hashing algorithm to be used. |
input |
ReadableStream.<Data>
|
The stream containing the message for which the signature has been generated. |
signature |
string
|
Buffer
|
The signature to be verified. |
inputEncoding |
string
|
The encoding of the |
signatureEncoding |
string
|
The encoding of the provided |
Returns:
- Type:
-
Promise.<boolean>
Wether the signature was valid or not.