Class for generating signatures.

Returned by Crypto.createSign.

Sign objects are writable streams. The written data is used to generate the signature. Once all of the data has been written, the sign method will return the signature.

The legacy update method is also supported.

Methods

sign(private_key:EitherType<String, {passphrase:String, key:String}>, output_format:String):String

sign(private_key:EitherType<String, {passphrase:String, key:String}>):Buffer

Calculates the signature on all the updated data passed through the sign. private_key is a string containing the PEM encoded private key for signing. Returns the signature in output_format which can be 'binary', 'hex' or 'base64'. If no encoding is provided, then a buffer is returned.

Note: sign object can not be used after sign method has been called.

update(data:String, ?encoding:String):Void

update(data:Buffer):Void

Updates the sign object with data. This can be called many times with new data as it is streamed.

Inherited Variables

Defined by Writable

read onlydestroyed:Bool

Is true after writable.destroy() has been called.

See also:

read onlyisTTY:Bool

Terminal write streams (i.e. process.stdout) have this property set to true. It is false for any other write streams.

See also:

read onlywritable:Bool

Is true if it is safe to call writable.write().

See also:

read onlywritableEnded:Bool

Is true after writable.end() has been called. This property does not indicate whether the data has been flushed, for this use writable.writableFinished instead.

See also:

read onlywritableFinished:Bool

Is set to true immediately before the 'finish' event is emitted.

See also:

read onlywritableLength:Int

This property contains the number of bytes (or objects) in the queue ready to be written. The value provides introspection data regarding the status of the highWaterMark.

See also:

read onlywritableObjectMode:Bool

Getter for the property objectMode of a given Writable stream.

See also:

read onlywritablehighWaterMark:Int

Return the value of highWaterMark passed when constructing this Writable.

See also:

Inherited Methods

Defined by Writable

cork():Void

The writable.cork() method forces all written data to be buffered in memory. The buffered data will be flushed when either the stream.uncork() or stream.end() methods are called.

See also:

destroy(?error:Error):TSelf

Destroy the stream. Optionally emit an 'error' event, and emit a 'close' event unless emitClose is set in false. After this call, the writable stream has ended and subsequent calls to write() or end() will result in an ERR_STREAM_DESTROYED error. This is a destructive and immediate way to destroy a stream. Previous calls to write() may not have drained, and may trigger an ERR_STREAM_DESTROYED error. Use end() instead of destroy if data should flush before close, or wait for the 'drain' event before destroying the stream. Implementors should not override this method, but instead implement writable._destroy().

See also:

end(chunk:Dynamic, ?encoding:String, ?callback:EitherType<() ‑> Void, Null<Error> ‑> Void>):Void

end(?callback:EitherType<() ‑> Void, Null<Error> ‑> Void>):Void

Calling the writable.end() method signals that no more data will be written to the Writable. The optional chunk and encoding arguments allow one final additional chunk of data to be written immediately before closing the stream. If provided, the optional callback function is attached as a listener for the 'finish' event.

See also:

setDefaultEncoding(encoding:String):TSelf

The writable.setDefaultEncoding() method sets the default encoding for a Writable stream.

See also:

uncork():Void

The writable.uncork() method flushes all data buffered since stream.cork() was called.

See also:

write(chunk:Dynamic, ?encoding:String, ?callback:EitherType<() ‑> Void, Null<Error> ‑> Void>):Bool

The writable.write() method writes some data to the stream, and calls the supplied callback once the data has been fully handled. If an error occurs, the callback may or may not be called with the error as its first argument. To reliably detect write errors, add a listener for the 'error' event.

See also:

Defined by EventEmitter

addListener<T>(eventName:Event<T>, listener:T):TSelf

emit<T>(eventName:Event<T>, args:Rest<Dynamic>):Bool

Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments to each.

See also:

eventNames():Array<EitherType<String, Symbol>>

Returns an array listing the events for which the emitter has registered listeners. The values in the array will be strings or Symbols.

See also:

getMaxListeners():Int

Returns the current max listener value for the EventEmitter which is either set by emitter.setMaxListeners(n) or defaults to EventEmitter.defaultMaxListeners.

See also:

listenerCount<T>(eventName:Event<T>):Int

Returns the number of listeners listening to the event named eventName.

See also:

listeners<T>(eventName:Event<T>):Array<T>

Returns a copy of the array of listeners for the event named eventName.

See also:

off<T>(eventName:Event<T>, listener:T):TSelf

on<T>(eventName:Event<T>, listener:T):TSelf

Adds the listener function to the end of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

See also:

once<T>(eventName:Event<T>, listener:T):TSelf

Adds a one-time listener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.

See also:

prependListener<T>(eventName:Event<T>, listener:T):TSelf

Adds the listener function to the beginning of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

See also:

prependOnceListener<T>(eventName:Event<T>, listener:T):TSelf

Adds a one-time listener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this listener is removed, and then invoked.

See also:

rawListeners<T>(eventName:Event<T>):Array<T>

Returns a copy of the array of listeners for the event named eventName, including any wrappers (such as those created by .once()).

See also:

removeAllListeners<T>(?eventName:Event<T>):TSelf

Removes all listeners, or those of the specified eventName.

See also:

removeListener<T>(eventName:Event<T>, listener:T):TSelf

Removes the specified listener from the listener array for the event named eventName.

See also:

setMaxListeners(n:Int):Void

By default EventEmitters will print a warning if more than 10 listeners are added for a particular event. This is a useful default that helps finding memory leaks. Obviously, not all events should be limited to just 10 listeners. The emitter.setMaxListeners() method allows the limit to be modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

See also: