Class Sm4CryptoProvider
SM4 国密算法加密提供者(使用 BouncyCastle 实现)
public class Sm4CryptoProvider : ICryptoProvider, IDisposable
- Inheritance
-
Sm4CryptoProvider
- Implements
- Inherited Members
Remarks
性能优化:
- 使用静态 SecureRandom 实例避免重复创建
- 使用 ArrayPool 减少内存分配
Constructors
Sm4CryptoProvider(byte[], Sm4Mode)
public Sm4CryptoProvider(byte[] key, Sm4Mode mode = Sm4Mode.CBC)
Parameters
Sm4CryptoProvider(string, Sm4Mode)
public Sm4CryptoProvider(string base64Key, Sm4Mode mode = Sm4Mode.CBC)
Parameters
Methods
Decrypt(string)
解密密文
public string Decrypt(string cipherText)
Parameters
cipherTextstring密文(Base64 编码)
Returns
- string
明文
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Encrypt(string)
加密明文
public string Encrypt(string plainText)
Parameters
plainTextstring明文
Returns
- string
密文(Base64 编码)