旧版流 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, the many of the crypto defined 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.】