Class Obfuscator
Provides methods for obfuscation of documents for reduced readability and size.
Namespace: Cuemon.Security
Assembly: Cuemon.Security.dll
Syntax
public abstract class Obfuscator
Constructors
| Improve this DocObfuscator()
Initializes a new instance of the Obfuscator class using System.Text.Encoding.Unicode for the character encoding.
Declaration
protected Obfuscator()
Obfuscator(IEnumerable<String>)
Initializes a new instance of the Obfuscator class using System.Text.Encoding.Unicode for the character encoding.
Declaration
protected Obfuscator(IEnumerable<string> exclusions)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | exclusions | A sequence of System.String values used for excluding matching original values in the obfuscation process. |
Obfuscator(Encoding)
Initializes a new instance of the Obfuscator class.
Declaration
protected Obfuscator(Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
System.Text.Encoding | encoding | The character encoding to use. |
Obfuscator(Encoding, IEnumerable<String>)
Initializes a new instance of the Obfuscator class.
Declaration
protected Obfuscator(Encoding encoding, IEnumerable<string> exclusions)
Parameters
Type | Name | Description |
---|---|---|
System.Text.Encoding | encoding | The character encoding to use. |
System.Collections.Generic.IEnumerable<System.String> | exclusions | A sequence of System.String values used for excluding matching original values in the obfuscation process. |
Properties
| Improve this DocCurrentCombinationLength
Gets the length of the current combination used in conjuction with CurrentPermutationSize.
Declaration
protected byte CurrentCombinationLength { get; }
Property Value
Type | Description |
---|---|
System.Byte | The length of the current combination used in conjuction with CurrentPermutationSize. |
CurrentPermutationSize
Gets the calculated size of the current permutation used in conjuction with CurrentCombinationLength.
Declaration
protected int CurrentPermutationSize { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The calculated size of the current permutation used in conjuction with CurrentCombinationLength. |
Encoding
Gets or sets the character encoding to use.
Declaration
public Encoding Encoding { get; set; }
Property Value
Type | Description |
---|---|
System.Text.Encoding | The character encoding to use. The default is System.Text.Encoding.Unicode. |
Exclusions
Gets a list of exclusions for the obfuscation process.
Declaration
protected ICollection<string> Exclusions { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.ICollection<System.String> | A list of exclusions for the obfuscation process. |
Mappings
Gets the generated mapping values associated with the obfuscated content.
Declaration
protected Dictionary<string, ObfuscatorMapping> Mappings { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, ObfuscatorMapping> | The original values gathered in a mappable structure. |
PermutationCharacters
Gets an System.Collections.Generic.IList<T> compatible object holding the characters initialized by InitializePermutationCharacters().
Declaration
protected IList<char> PermutationCharacters { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IList<System.Char> | An System.Collections.Generic.IList<T> compatible object holding the characters initialized by InitializePermutationCharacters(). |
Methods
| Improve this DocComputeHash(String)
Computes a SHA-1 hash value of the specified System.String value.
Declaration
protected virtual string ComputeHash(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The System.String value to compute a hash code for. |
Returns
Type | Description |
---|---|
System.String | A System.String containing the computed SHA-1 hash value of |
Remarks
Do override this method if you prefer another hashing than SHA-1.
CreateMapping()
Creates and returns a mappaple format of the original values and the obfuscated values.
Declaration
public abstract Stream CreateMapping()
Returns
Type | Description |
---|---|
System.IO.Stream | A mappaple format of the original values and the obfuscated values. |
GenerateObfuscatedValue()
Creates and returns a random generated System.String with a factorial size of (x - CurrentCombinationLength) ideal for obfuscated usage.
Declaration
protected string GenerateObfuscatedValue()
Returns
Type | Description |
---|---|
System.String | A random generated System.String with a factorial size of (x - CurrentCombinationLength) ideal for obfuscated usage, where x in the default implementation equals 62. |
Remarks
This implementation uses the values from PermutationCharacters to compute the permutation. Using the standard implementation gives a close to limitless permutation in regards to obfuscation, as the value automatically grows when needed.
InitializePermutationCharacters()
Initializes the permutation characters used in the obfuscation process.
Declaration
protected virtual IList<char> InitializePermutationCharacters()
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<System.Char> | An System.Collections.Generic.IList<T> compatible object holding the permuation characters used in the obfuscation process. |
Remarks
Override this method to implement your own initialization of permuation characters. Default implementation is initialized as a read-only System.Collections.Generic.IList<T> compatible object with the values found in AlphanumericCharactersCaseSensitive.
Obfuscate(Stream)
Obfuscates the values of the specified System.IO.Stream object.
Declaration
public abstract Stream Obfuscate(Stream value)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | value | The System.IO.Stream object to obfuscate. |
Returns
Type | Description |
---|---|
System.IO.Stream | A System.IO.Stream object where the values has been obfuscated. |
Revert(Stream, Stream)
Revert the obfuscated value of value
to its original state by applying the mappaple values of mapping
.
Declaration
public abstract Stream Revert(Stream value, Stream mapping)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | value | The obfuscated System.IO.Stream to revert. |
System.IO.Stream | mapping | A System.IO.Stream containing mappaple values necessary to revert |
Returns
Type | Description |
---|---|
System.IO.Stream | A System.IO.Stream object where the obfuscated value has been reverted to its original value. |