Pkcs8PrivateKeyInfo.Encrypt 方法
定义
重载
| Encrypt(ReadOnlySpan<Byte>, PbeParameters) |
在使用指定的基于字节的密码和加密参数进行加密后,根据此对象的属性内容生成 PKCS#8 EncryptedPrivateKeyInfo。Produces a PKCS#8 EncryptedPrivateKeyInfo from the property contents of this object after encrypting with the specified byte-based password and encryption parameters. |
| Encrypt(ReadOnlySpan<Char>, PbeParameters) |
在使用指定的基于字符的密码和加密参数进行加密后,根据此对象的属性内容生成 PKCS#8 EncryptedPrivateKeyInfo。Produces a PKCS#8 EncryptedPrivateKeyInfo from the property contents of this object after encrypting with the specified character-based password and encryption parameters. |
Encrypt(ReadOnlySpan<Byte>, PbeParameters)
在使用指定的基于字节的密码和加密参数进行加密后,根据此对象的属性内容生成 PKCS#8 EncryptedPrivateKeyInfo。Produces a PKCS#8 EncryptedPrivateKeyInfo from the property contents of this object after encrypting with the specified byte-based password and encryption parameters.
public:
cli::array <System::Byte> ^ Encrypt(ReadOnlySpan<System::Byte> passwordBytes, System::Security::Cryptography::PbeParameters ^ pbeParameters);
public byte[] Encrypt (ReadOnlySpan<byte> passwordBytes, System.Security.Cryptography.PbeParameters pbeParameters);
member this.Encrypt : ReadOnlySpan<byte> * System.Security.Cryptography.PbeParameters -> byte[]
Public Function Encrypt (passwordBytes As ReadOnlySpan(Of Byte), pbeParameters As PbeParameters) As Byte()
参数
- passwordBytes
- ReadOnlySpan<Byte>
加密密钥材料时用作密码的字节。The bytes to use as a password when encrypting the key material.
- pbeParameters
- PbeParameters
加密密钥材料时使用的基于密码加密 (PBE) 参数。The password-based encryption (PBE) parameters to use when encrypting the key material.
返回
- Byte[]
一个字节数组,其中包含 PKCS#8 EncryptedPrivateKeyInfo 的编码形式。A byte array containing the encoded form of the PKCS#8 EncryptedPrivateKeyInfo.
例外
pbeParameters 指示应使用需要基于 Char 密码的 TripleDes3KeyPkcs12。pbeParameters indicates that TripleDes3KeyPkcs12 should be used, which requires Char-based passwords.
注解
密码字节直接传递到密钥派生函数 (KDF) 使用的算法所使用的算法 pbeParameters 。The password bytes are passed directly into the Key Derivation Function (KDF) used by the algorithm indicated by pbeParameters.
这样,在使用 PBKDF2 处理密码时,与使用 UTF-8 以外的文本编码的其他系统兼容, (基于密码的密钥派生函数 2) 。This enables compatibility with other systems which use a text encoding other than UTF-8 when processing passwords with PBKDF2 (Password-Based Key Derivation Function 2).
另请参阅
适用于
Encrypt(ReadOnlySpan<Char>, PbeParameters)
在使用指定的基于字符的密码和加密参数进行加密后,根据此对象的属性内容生成 PKCS#8 EncryptedPrivateKeyInfo。Produces a PKCS#8 EncryptedPrivateKeyInfo from the property contents of this object after encrypting with the specified character-based password and encryption parameters.
public:
cli::array <System::Byte> ^ Encrypt(ReadOnlySpan<char> password, System::Security::Cryptography::PbeParameters ^ pbeParameters);
public byte[] Encrypt (ReadOnlySpan<char> password, System.Security.Cryptography.PbeParameters pbeParameters);
member this.Encrypt : ReadOnlySpan<char> * System.Security.Cryptography.PbeParameters -> byte[]
Public Function Encrypt (password As ReadOnlySpan(Of Char), pbeParameters As PbeParameters) As Byte()
参数
- password
- ReadOnlySpan<Char>
加密密钥材料时使用的密码。The password to use when encrypting the key material.
- pbeParameters
- PbeParameters
加密密钥材料时使用的基于密码加密 (PBE) 参数。The password-based encryption (PBE) parameters to use when encrypting the key material.
返回
- Byte[]
一个字节数组,其中包含 PKCS#8 EncryptedPrivateKeyInfo 的编码形式。A byte array containing the encoded form of the PKCS#8 EncryptedPrivateKeyInfo.
注解
当 pbeParameters 指示使用 PBKDF2 (基于密码的密钥派生函数 2) 的算法时,密码将通过 utf-8 编码转换为字节。When pbeParameters indicates an algorithm that uses PBKDF2 (Password-Based Key Derivation Function 2), the password is converted to bytes via the UTF-8 encoding.