easy-crypto/signature

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 message. If message is a string and no value is provided, an encoding of 'utf8' will be enforced. Ignored if message is a Buffer, TypedArray or DataView.

outputEncoding string

The encoding of the output signature. If provided a string is returned, otherwise a Buffer is returned.

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 message. If message is a string and no value is provided, an encoding of 'utf8' will be enforced. Ignored if message is a Buffer, TypedArray or DataView.

outputEncoding string

The encoding of the output signature. If provided a string is returned, otherwise a Buffer is returned.

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 message. If message is a string and no value is provided, an encoding of 'utf8' will be enforced. Ignored if message is a Buffer, TypedArray or DataView.

signatureEncoding string

The encoding of the provided signature. If a signatureEncoding is specified, the signature is expected to be a string; otherwise signature is expected to be a Buffer, TypedArray, or DataView.

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 message. If message is a string and no value is provided, an encoding of 'utf8' will be enforced. Ignored if message is a Buffer, TypedArray or DataView.

signatureEncoding string

The encoding of the provided signature. If a signatureEncoding is specified, the signature is expected to be a string; otherwise signature is expected to be a Buffer, TypedArray, or DataView.

Returns:
Type:
Promise.<boolean>

Wether the signature was valid or not.