diffieHellman.generateKeys([encoding])


生成私有和公共 Diffie-Hellman 密钥值(除非它们已生成或计算),并返回指定 encoding 中的公共密钥。此密钥应转让给另一方。如果提供了 encoding,则返回一个字符串;否则返回 Buffer

¥Generates private and public Diffie-Hellman key values unless they have been generated or computed already, and returns the public key in the specified encoding. This key should be transferred to the other party. If encoding is provided a string is returned; otherwise a Buffer is returned.

该函数是 DH_generate_key() 的薄封装。特别是,一旦生成或设置了私钥,调用此函数只会更新公钥,但不会生成新的私钥。

¥This function is a thin wrapper around DH_generate_key(). In particular, once a private key has been generated or set, calling this function only updates the public key but does not generate a new private key.