KeyObject 类
Node.js 使用 KeyObject
类来表示对称或非对称密钥,每种密钥暴露不同的功能。
crypto.createSecretKey()
、crypto.createPublicKey()
和 crypto.createPrivateKey()
方法用于创建 KeyObject
实例。
KeyObject
对象不能直接使用 new
关键字创建。
由于改进的安全功能,大多数应用程序应该考虑使用新的 KeyObject
API 而不是将密钥作为字符串或 Buffer
传入。
KeyObject
实例可以通过 postMessage()
传给其他线程。
接收者获得克隆的 KeyObject
,KeyObject
不需要在 transferList
参数中列出。
Node.js uses a KeyObject
class to represent a symmetric or asymmetric key,
and each kind of key exposes different functions. The
crypto.createSecretKey()
, crypto.createPublicKey()
and
crypto.createPrivateKey()
methods are used to create KeyObject
instances. KeyObject
objects are not to be created directly using the new
keyword.
Most applications should consider using the new KeyObject
API instead of
passing keys as strings or Buffer
s due to improved security features.
KeyObject
instances can be passed to other threads via postMessage()
.
The receiver obtains a cloned KeyObject
, and the KeyObject
does not need to
be listed in the transferList
argument.