class Decipher
package js.node.crypto
extends Transform › Duplex › Readable › Stream › EventEmitter
Class for decrypting data.
Returned by Crypto.createDecipher
and Crypto.createDecipheriv
.
Decipher objects are streams that are both readable and writable. The written enciphered data is used to produce the plain-text data on the the readable side.
The legacy update
and final
methods are also supported.
Methods
finalContents(output_encoding:String):String
final():Buffer
Returns any remaining plaintext which is deciphered,
with output_encoding
being one of: 'binary', 'ascii' or 'utf8'.
If no encoding is provided, then a buffer is returned.
Note: decipher object can not be used after final
method has been called.
setAAD(buffer:Buffer):Void
For authenticated encryption modes (currently supported: GCM), this method sets the value used for the additional authenticated data (AAD) input parameter.
setAuthTag(buffer:Buffer):Void
For authenticated encryption modes (currently supported: GCM), this method must be used
to pass in the received authentication tag. If no tag is provided or if the ciphertext
has been tampered with, final
will throw, thus indicating that the ciphertext should be
discarded due to failed authentication.
setAutoPadding(auto_padding:Bool):Void
setAutoPadding():Void
You can disable auto padding if the data has been encrypted without standard block padding
to prevent final
from checking and removing it.
Can only work if the input data's length is a multiple of the ciphers block size.
You must call this before streaming data to update
.
update(data:String, input_encoding:String, output_encoding:String):String
update(data:Buffer):Buffer
update(data:String, input_encoding:String):Buffer
Updates the decipher with data
, which is encoded in 'binary', 'base64' or 'hex'.
If no encoding is provided, then a buffer is expected.
The output_decoding
specifies in what format to return the deciphered plaintext: 'binary', 'ascii' or 'utf8'.
If no encoding is provided, then a buffer is returned.