decipher.update(data[, inputEncoding][, outputEncoding])


使用 data 更新解码器。如果提供了 inputEncoding 参数,data 参数就是使用指定编码的字符串。如果没有提供 inputEncoding 参数,data 必须是 Buffer、TypedArray 或 DataView。如果 data 是 Buffer、TypedArray 或 DataView,那么 inputEncoding 会被忽略。

🌐 Updates the decipher with data. If the inputEncoding argument is given, the data argument is a string using the specified encoding. If the inputEncoding argument is not given, data must be a Buffer, TypedArray, or DataView. If data is a Buffer, TypedArray, or DataView, then inputEncoding is ignored.

outputEncoding 指定了解密数据的输出格式。如果指定了 outputEncoding,则返回使用指定编码的字符串。如果没有提供 outputEncoding,则返回一个 Buffer。当指定 outputEncoding 时,它必须使用与之前调用 decipher.update() 相同的编码。

🌐 The outputEncoding specifies the output format of the deciphered data. If the outputEncoding is specified, a string using the specified encoding is returned. If no outputEncoding is provided, a Buffer is returned. When outputEncoding is specified, it must use the same encoding as previous calls to decipher.update().

对于大多数算法,可以多次调用 decipher.update() 来处理新数据,直到调用 decipher.final()。有些算法限制对 decipher.update() 的调用。例如,CCM 模式、CBC-CTS 模式、XTS模式、AES 密钥封装模式 和 SIV 和 GCM-SIV 模式 需要在一次调用中提供完整的消息。在 decipher.final() 之后调用 decipher.update() 会导致抛出错误。

🌐 For most algorithms, decipher.update() can be called multiple times with new data until decipher.final() is called. Some algorithms restrict calls to decipher.update(). For example, CCM mode, CBC-CTS mode, XTS mode, AES key wrap modes, and SIV and GCM-SIV modes require the whole message in a single call. Calling decipher.update() after decipher.final() will result in an error being thrown.

即使底层密码实现了认证,从此函数返回的明文的真实性和完整性此时可能仍不确定。对于经过认证的加密算法,只有在应用调用 decipher.final() 时,通常才能确定其真实性。

🌐 Even if the underlying cipher implements authentication, the authenticity and integrity of the plaintext returned from this function may be uncertain at this time. For authenticated encryption algorithms, authenticity is generally only established when the application calls decipher.final().