Class SensitiveByteArray
- Namespace
- WhalesSecret.TradeScriptLib.Entities
- Assembly
- WhalesSecret.TradeScriptLib.dll
The class wraps a sensitive byte array and zeros out its content on instance disposal.
This is best-effort approach that cannot make any guarantees. Especially since it is not possible to prevent memory swapping to disk.
public class SensitiveByteArray : IDisposable, IEquatable<SensitiveByteArray>
- Inheritance
-
SensitiveByteArray
- Implements
- Inherited Members
- Extension Methods
Constructors
- SensitiveByteArray(int)
Creates a new instance of the object.
Properties
- Data
Provides full access span to the underlying data.
- this[int]
Implements indexer so that callers can use this class just as they would with normal byte array.
- ReadOnlyData
Provides read-only access to the underlying data.
Methods
- Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- Dispose(bool)
Frees resources used by the object. Both kinds of resources managed and unmanaged are freed based on whether the method is called from Dispose() or not.
Clears underlying byte array to make it harder to read data from memory.
- Equals(object?)
Determines whether the specified object is equal to the current object.
- Equals(SensitiveByteArray?)
Indicates whether the current object is equal to another object of the same type.
- GetHashCode()
Serves as the default hash function.
Operators
- operator ==(SensitiveByteArray?, SensitiveByteArray?)
Determines whether two specified sensitive byte arrays have the same value.
- implicit operator SensitiveByteArray(byte[])
Allows conversion from byte array to SensitiveByteArray. This should be used only if a third party API returns sensitive content in byte array.
- implicit operator SensitiveByteArray(ReadOnlySpan<byte>)
Allows conversion from read-only span to SensitiveByteArray. This should be used only if a third party API returns sensitive content in byte array.
- implicit operator byte[](SensitiveByteArray)
Allows conversion from SensitiveByteArray to byte array. This should be used only if a third party API accepts byte array and we have it as SensitiveByteArray.
- operator !=(SensitiveByteArray?, SensitiveByteArray?)
Determines whether two specified sensitive byte arrays have different values.