Table of Contents

Class ChaCha20CryptoProvider

Namespace
Apq.Cfg.Crypto.Providers
Assembly
Apq.Cfg.Crypto.dll

ChaCha20-Poly1305 加密提供者(使用 BouncyCastle 实现)

public class ChaCha20CryptoProvider : ICryptoProvider, IDisposable
Inheritance
ChaCha20CryptoProvider
Implements
Inherited Members

Remarks

性能优化:

  1. 使用静态 SecureRandom 实例避免重复创建
  2. 使用 ArrayPool 减少内存分配

Constructors

ChaCha20CryptoProvider(byte[])

public ChaCha20CryptoProvider(byte[] key)

Parameters

key byte[]

ChaCha20CryptoProvider(string)

public ChaCha20CryptoProvider(string base64Key)

Parameters

base64Key string

Methods

Decrypt(string)

解密密文

public string Decrypt(string cipherText)

Parameters

cipherText string

密文(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

plainText string

明文

Returns

string

密文(Base64 编码)