旧版流 API(Node.js 0.10 之前)


【Legacy streams API (prior to Node.js 0.10)】

在出现统一的 Stream API 概念之前,以及出现用于处理二进制数据的 Buffer 对象之前,Crypto 模块就已被添加到 Node.js 中。因此,许多 crypto 类具有在实现 溪流 API 的其他 Node.js 类中不常见的方法(例如 update()final()digest())。此外,许多方法默认接受和返回 'latin1' 编码的字符串,而不是 Buffer。在 Node.js v0.8 之后,这一默认行为已更改,默认使用 Buffer 对象。

【The Crypto module was added to Node.js before there was the concept of a unified Stream API, and before there were Buffer objects for handling binary data. As such, many crypto classes have methods not typically found on other Node.js classes that implement the streams API (e.g. update(), final(), or digest()). Also, many methods accepted and returned 'latin1' encoded strings by default rather than Buffers. This default was changed after Node.js v0.8 to use Buffer objects by default instead.】