The class for creating Diffie-Hellman key exchanges. Returned by Crypto.createDiffieHellman.

Methods

computeSecret(other_public_key:String, input_encoding:String, output_encoding:String):String

computeSecret(other_public_key:Buffer):Buffer

computeSecret(other_public_key:String, input_encoding:String):Buffer

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 the input encoding is not provided, then a buffer is expected.

generateKeys(encoding:String):String

generateKeys():Buffer

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'.

getGenerator(encoding:String):String

getGenerator():Buffer

Returns the Diffie-Hellman generator in the specified encoding, which can be 'binary', 'hex', or 'base64'. If no encoding is provided, then a buffer is returned.

getPrime(encoding:String):String

getPrime():Buffer

Returns the Diffie-Hellman prime in the specified encoding, which can be 'binary', 'hex', or 'base64'. If no encoding is provided, then a buffer is returned.

getPrivateKey(encoding:String):String

getPrivateKey():Buffer

Returns the Diffie-Hellman private key in the specified encoding, which can be 'binary', 'hex', or 'base64'. If no encoding is provided, then a buffer is returned.

getPublicKey(encoding:String):String

getPublicKey():Buffer

Returns the Diffie-Hellman public key in the specified encoding, which can be 'binary', 'hex', or 'base64'. If no encoding is provided, then a buffer is returned.

setPrivateKey(private_key:String, encoding:String):Void

setPrivateKey(private_key:Buffer):Void

Sets the Diffie-Hellman private key. Key encoding can be 'binary', 'hex' or 'base64'. If no encoding is provided, then a Buffer is expected.

setPublicKey(public_key:String, encoding:String):Void

setPublicKey(public_key:Buffer):Void

Sets the Diffie-Hellman public key. Key encoding can be 'binary', 'hex' or 'base64'. If no encoding is provided, then a Buffer is expected.