of OpenSSL on the platform. Examples are `'sha1'`, `'md5'`, `'sha256'`, `'sha512'`, etc.
On recent releases, `openssl list-message-digest-algorithms` will display the available digest algorithms.
+Example: this program that takes the sha1 sum of a file
+
+ var filename = process.argv[2];
+ var crypto = require('crypto');
+ var fs = require('fs');
+
+ var shasum = crypto.createHash('sha1');
+
+ var s = fs.ReadStream(filename);
+ s.on('data', function(d) {
+ shasum.update(d);
+ });
+
+ s.on('end', function() {
+ var d = shasum.digest('hex');
+ console.log(d + ' ' + filename);
+ });
+
### hash.update(data)
Updates the hash content with the given `data`.
Calculates the digest of all of the passed data to be hashed.
The `encoding` can be `'hex'`, `'binary'` or `'base64'`.
+Note: `hash` object can not be used after `digest()` method been called.
+
### crypto.createHmac(algorithm, key)
Calculates the digest of all of the passed data to the hmac.
The `encoding` can be `'hex'`, `'binary'` or `'base64'`.
+Note: `hmac` object can not be used after `digest()` method been called.
+
-### crypto.createCipher(algorithm, key)
+### crypto.createCipher(algorithm, password)
-Creates and returns a cipher object, with the given algorithm and key.
+Creates and returns a cipher object, with the given algorithm and password.
`algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc.
-On recent releases, `openssl list-cipher-algorithms` will display the available cipher algorithms.
+On recent releases, `openssl list-cipher-algorithms` will display the
+available cipher algorithms.
+`password` is used to derive key and IV, which must be `'binary'` encoded
+string (See the [Buffers](buffers.html) for more information).
+
+### crypto.createCipheriv(algorithm, key, iv)
+
+Creates and returns a cipher object, with the given algorithm, key and iv.
+
+`algorithm` is the same as the `createCipher()`. `key` is a raw key used in
+algorithm. `iv` is an Initialization vector. `key` and `iv` must be `'binary'`
+encoded string (See the [Buffers](buffers.html) for more information).
### cipher.update(data, input_encoding='binary', output_encoding='binary')
### cipher.final(output_encoding='binary')
-Returns any remaining enciphered contents, with `output_encoding` being one of: `'binary'`, `'ascii'` or `'utf8'`.
+Returns any remaining enciphered contents, with `output_encoding` being one of: `'binary'`, `'base64'` or `'hex'`.
-### crypto.createDecipher(algorithm, key)
+Note: `cipher` object can not be used after `final()` method been called.
+
+
+### crypto.createDecipher(algorithm, password)
Creates and returns a decipher object, with the given algorithm and key.
-This is the mirror of the cipher object above.
+This is the mirror of the [createCipher()](#crypto.createCipher) above.
+
+### crypto.createDecipheriv(algorithm, key, iv)
+
+Creates and returns a decipher object, with the given algorithm, key and iv.
+This is the mirror of the [createCipheriv()](#crypto.createCipheriv) above.
### decipher.update(data, input_encoding='binary', output_encoding='binary')
### decipher.final(output_encoding='binary')
Returns any remaining plaintext which is deciphered,
-with `output_encoding' being one of: `'binary'`, `'ascii'` or `'utf8'`.
+with `output_encoding` being one of: `'binary'`, `'ascii'` or `'utf8'`.
+
+Note: `decipher` object can not be used after `final()` method been called.
### crypto.createSign(algorithm)
Returns the signature in `output_format` which can be `'binary'`, `'hex'` or `'base64'`.
+Note: `signer` object can not be used after `sign()` method been called.
+
+
### crypto.createVerify(algorithm)
Creates and returns a verification object, with the given algorithm.
### verifier.update(data)
-Updates the verifyer object with data.
+Updates the verifier object with data.
This can be called many times with new data as it is streamed.
-### verifier.verify(public_key, signature, signature_format='binary')
+### verifier.verify(object, signature, signature_format='binary')
-Verifies the signed data by using the `public_key` which is a string containing
-the PEM encoded public key, and `signature`, which is the previously calculates
-signature for the data, in the `signature_format` which can be `'binary'`, `'hex'` or `'base64'`.
+Verifies the signed data by using the `object` and `signature`. `object` is a
+string containing a PEM encoded object, which can be one of RSA public key,
+DSA public key, or X.509 certificate. `signature` is the previously calculated
+signature for the data, in the `signature_format` which can be `'binary'`,
+`'hex'` or `'base64'`.
Returns true or false depending on the validity of the signature for the data and public key.
+
+Note: `verifier` object can not be used after `verify()` method been called.
+
+### crypto.createDiffieHellman(prime_length)
+
+Creates a Diffie-Hellman key exchange object and generates a prime of the
+given bit length. The generator used is `2`.
+
+### crypto.createDiffieHellman(prime, encoding='binary')
+
+Creates a Diffie-Hellman key exchange object using the supplied prime. The
+generator used is `2`. Encoding can be `'binary'`, `'hex'`, or `'base64'`.
+
+### diffieHellman.generateKeys(encoding='binary')
+
+Generates private and public Diffie-Hellman key values, and returns the
+public key in the specified encoding. This key should be transferred to the
+other party. Encoding can be `'binary'`, `'hex'`, or `'base64'`.
+
+### diffieHellman.computeSecret(other_public_key, input_encoding='binary', output_encoding=input_encoding)
+
+Computes the shared secret using `other_public_key` as the other party's
+public key and returns the computed shared secret. Supplied key is
+interpreted using specified `input_encoding`, and secret is encoded using
+specified `output_encoding`. Encodings can be `'binary'`, `'hex'`, or
+`'base64'`. If no output encoding is given, the input encoding is used as
+output encoding.
+
+### diffieHellman.getPrime(encoding='binary')
+
+Returns the Diffie-Hellman prime in the specified encoding, which can be
+`'binary'`, `'hex'`, or `'base64'`.
+
+### diffieHellman.getGenerator(encoding='binary')
+
+Returns the Diffie-Hellman prime in the specified encoding, which can be
+`'binary'`, `'hex'`, or `'base64'`.
+
+### diffieHellman.getPublicKey(encoding='binary')
+
+Returns the Diffie-Hellman public key in the specified encoding, which can
+be `'binary'`, `'hex'`, or `'base64'`.
+
+### diffieHellman.getPrivateKey(encoding='binary')
+
+Returns the Diffie-Hellman private key in the specified encoding, which can
+be `'binary'`, `'hex'`, or `'base64'`.
+
+### diffieHellman.setPublicKey(public_key, encoding='binary')
+
+Sets the Diffie-Hellman public key. Key encoding can be `'binary'`, `'hex'`,
+or `'base64'`.
+
+### diffieHellman.setPrivateKey(public_key, encoding='binary')
+
+Sets the Diffie-Hellman private key. Key encoding can be `'binary'`, `'hex'`, or `'base64'`.
+