Search Results for

    Show / Hide Table of Contents
    View Source

    Class HashGenerator

    Used to generate a string hash using crypto libraries over multiple objects

    Inheritance
    object
    DisposableObjectSlim
    Namespace: Umbraco.Cms.Core
    Assembly: Umbraco.Core.dll
    Syntax
    public class HashGenerator : DisposableObjectSlim
    Remarks

    This should be used to generate a reliable hash that survives AppDomain restarts. This will use the crypto libs to generate the hash and will try to ensure that strings, etc... are not re-allocated so it's not consuming much memory.

    Constructors

    View Source

    HashGenerator()

    Initializes a new instance of the HashGenerator class.

    Declaration
    public HashGenerator()

    Methods

    View Source

    AddCaseInsensitiveString(string)

    Adds a string to the hash computation in a case-insensitive manner.

    Declaration
    public void AddCaseInsensitiveString(string s)
    Parameters
    Type Name Description
    string s

    The string to add. If null, nothing is added.

    Remarks

    The string is converted to uppercase before being added to ensure case-insensitive hash generation.

    View Source

    AddDateTime(DateTime)

    Adds a DateTime value to the hash computation using its ticks.

    Declaration
    public void AddDateTime(DateTime d)
    Parameters
    Type Name Description
    DateTime d

    The DateTime value to add.

    View Source

    AddFile(FileInfo)

    Adds a file to the hash computation.

    Declaration
    public void AddFile(FileInfo f)
    Parameters
    Type Name Description
    FileInfo f

    The file to add.

    View Source

    AddFileSystemItem(FileSystemInfo)

    Adds a file system item (file or directory) to the hash computation.

    Declaration
    public void AddFileSystemItem(FileSystemInfo f)
    Parameters
    Type Name Description
    FileSystemInfo f

    The file system item to add.

    Remarks

    For files, adds the full name, creation time, last write time, and length. For directories, recursively adds all files and subdirectories.

    View Source

    AddFolder(DirectoryInfo)

    Adds a folder and its contents to the hash computation.

    Declaration
    public void AddFolder(DirectoryInfo d)
    Parameters
    Type Name Description
    DirectoryInfo d

    The directory to add.

    View Source

    AddInt(int)

    Adds an integer value to the hash computation.

    Declaration
    public void AddInt(int i)
    Parameters
    Type Name Description
    int i

    The integer value to add.

    View Source

    AddLong(long)

    Adds a long value to the hash computation.

    Declaration
    public void AddLong(long i)
    Parameters
    Type Name Description
    long i

    The long value to add.

    View Source

    AddObject(object)

    Adds an object's string representation to the hash computation.

    Declaration
    public void AddObject(object o)
    Parameters
    Type Name Description
    object o

    The object to add.

    View Source

    AddString(string)

    Adds a string to the hash computation.

    Declaration
    public void AddString(string s)
    Parameters
    Type Name Description
    string s

    The string to add. If null, nothing is added.

    View Source

    DisposeResources()

    Disposes managed resources

    Declaration
    protected override void DisposeResources()
    View Source

    GenerateHash()

    Returns the generated hash of all added objects.

    Declaration
    public string GenerateHash()
    Returns
    Type Description
    string

    A hexadecimal string representation of the computed hash.

    Remarks

    Uses SHA1 when FIPS compliance is required, otherwise uses MD5. This method can be called multiple times; subsequent calls will include any objects added after the previous call.

    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX