SymmetricAlgorithm.Clear SymmetricAlgorithm.Clear SymmetricAlgorithm.Clear SymmetricAlgorithm.Clear Method

定义

释放 SymmetricAlgorithm 类使用的所有资源。Releases all resources used by the SymmetricAlgorithm class.

public:
 void Clear();
public void Clear ();
member this.Clear : unit -> unit
Public Sub Clear ()

注解

请注意,当使用派生类,它是不足够,从安全角度看,只需使用对象完成强制垃圾回收。Note that when using derived classes, it is not enough, from a security perspective, to simply force a garbage collection after you have finished using the object. 必须显式调用Clear中进行发布之前的对象的任何敏感数据清零的对象上的方法。You must explicitly call the Clear method on the object to zero out any sensitive data within the object before it is released. 请注意,垃圾回收不会收集的对象的内容不为零,但只需将标记为可用于重新分配内存。Note that garbage collection does not zero out the contents of collected objects but simply marks the memory as available for reallocation. 因此垃圾回收对象中包含的数据仍可能存在内存堆中分配的内存中。Thus the data contained within a garbage collected object may still be present in the memory heap in unallocated memory. 对于加密对象,此数据可能包含敏感信息,如关键数据或纯文本块。In the case of cryptographic objects, this data could contain sensitive information such as key data or a block of plain text.

.NET Framework 中保留敏感的数据实现的所有加密类Clear方法。All cryptographic classes in the .NET Framework that hold sensitive data implement a Clear method. 调用时,Clear方法用零覆盖在对象中的所有敏感数据,然后释放该对象,以便它可以安全地进行垃圾回收。When called, the Clear method overwrites all sensitive data within the object with zeros and then releases the object so that it can be safely garbage collected. 当归零对象并将其发布时,然后应调用Dispose方法替换disposing参数设置为True释放所有托管和非托管资源与对象相关联。When the object has been zeroed and released, you should then call the Dispose method with the disposing parameter set to True to dispose of all managed and unmanaged resources associated with the object.

适用于

另请参阅