2 - Unstable
The crypto module offers a way of encapsulating secure credentials to be used
as part of a secure HTTPS net or HTTP connection. To access this module, add
require('crypto') to your code.
The module also offers a set of wrappers for OpenSSL's methods, which actually contains these objects:
This documentation is organized to describe those objects within their own sections.
Note:
Allalgorithm parameter implementations below are dependent on the OpenSSL version installed on the platform. Some common examples of these algoritihms are 'sha1', 'md5', 'sha256', and 'sha512'. On recent Node.js releases, openssl list-message-digest-algorithms displays the available digest algorithms.
Example
Proposed API Changes in Future Versions of Node
The Crypto module was added to Node before there was the concept of a unified Stream API, and before there were Buffer objects for handling binary data.
As such, the streaming classes don't have the typical methods found on other Node classes, and many methods accept and return Binary-encoded strings by default rather than Buffers.
A future version of node will make Buffers the default data type. This will be a breaking change for some use cases, but not all.
For example, if you currently use the default arguments to the Sign class, and then pass the results to the Verify class, without ever inspecting the data, then it will continue to work as before. Where you now get a binary string and then present the binary string to the Verify object, you'll get a Buffer, and present the Buffer to the Verify object.
However, if you are doing things with the string data that will not work properly on Buffers (such as, concatenating them, storing in databases, etc.), or you are passing binary strings to the crypto functions without an encoding argument, then you will need to start providing encoding arguments to specify which encoding you'd like to use.
Also, a Streaming API will be provided, but this will be done in such a way as to preserve the legacy API surface.
