crypto.createPrivateKey(key)
- key<Object> | <string> | <ArrayBuffer> | <Buffer> | <TypedArray> | <DataView>- key: <string> | <ArrayBuffer> | <Buffer> | <TypedArray> | <DataView> | <Object> 密钥材料,采用 PEM、DER 或 JWK 格式。
- format: <string> 必须是- 'pem'、- 'der'或 '- 'jwk'。 默认值:- 'pem'。
- type: <string> 必须是- 'pkcs1'、- 'pkcs8'或- 'sec1'。 仅当- format为- 'der'时才需要此选项,否则将被忽略。
- passphrase: <string> | <Buffer> 用于解密的密码。
- encoding: <string> 当- key是字符串时使用的字符串编码。
 
- 返回: <KeyObject>
创建并返回包含私钥的新密钥对象。
如果 key 是字符串或 Buffer,则假定 format 是 'pem';否则,key 必须是具有上述属性的对象。
如果私钥被加密,则必须指定 passphrase。
密码的长度限制为 1024 字节。
- key<Object> | <string> | <ArrayBuffer> | <Buffer> | <TypedArray> | <DataView>- key: <string> | <ArrayBuffer> | <Buffer> | <TypedArray> | <DataView> | <Object> The key material, either in PEM, DER, or JWK format.
- format: <string> Must be- 'pem',- 'der', or '- 'jwk'. Default:- 'pem'.
- type: <string> Must be- 'pkcs1',- 'pkcs8'or- 'sec1'. This option is required only if the- formatis- 'der'and ignored otherwise.
- passphrase: <string> | <Buffer> The passphrase to use for decryption.
- encoding: <string> The string encoding to use when- keyis a string.
 
- Returns: <KeyObject>
Creates and returns a new key object containing a private key. If key is a
string or Buffer, format is assumed to be 'pem'; otherwise, key
must be an object with the properties described above.
If the private key is encrypted, a passphrase must be specified. The length
of the passphrase is limited to 1024 bytes.