#include <opennurbs_sha1.h>

Public Member Functions

 ON_SHA1_Hash ()
 The default constructor creates a zero digest sha1 hash. More...
 
 ON_SHA1_Hash (const ON_SHA1_Hash &)=default
 
 ~ON_SHA1_Hash ()=default
 
void Dump (class ON_TextLog &text_log) const
 
bool IsEmptyContentHash () const
 
bool IsZeroDigentOrEmptyContentHash () const
 
bool IsZeroDigest () const
 
ON_SHA1_Hashoperator= (const ON_SHA1_Hash &)=default
 
bool Read (class ON_BinaryArchive &archive)
 
const ON_wString ToString (bool bUpperCaseHexadecimalDigits) const
 
const ON_String ToUTF8String (bool bUpperCaseHexadecimalDigits) const
 
bool Write (class ON_BinaryArchive &archive) const
 

Static Public Member Functions

static ON_SHA1_Hash BufferContentHash (const void *buffer, size_t sizeof_buffer)
 
static int Compare (const ON_SHA1_Hash &a, const ON_SHA1_Hash &b)
 
static ON_SHA1_Hash FileContentHash (const wchar_t *file_name, ON__UINT64 &sizeof_file)
 
static ON_SHA1_Hash FileContentHash (const char *file_name, ON__UINT64 &sizeof_file)
 
static ON_SHA1_Hash FileContentHash (FILE *file, ON__UINT64 &sizeof_file)
 
static ON_SHA1_Hash FileSystemPathHash (const wchar_t *path)
 Return a hash of the file system path that is independent of the size of wchar_t, constant across platforms, and constant across varations in the way the path is formatted. More...
 
static ON_SHA1_Hash FileSystemPathHash (const char *path)
 
static ON_SHA1_Hash FileSystemPathHash (const wchar_t *path, bool bIgnoreCase)
 
static ON_SHA1_Hash FileSystemPathHash (const char *path, bool bIgnoreCase)
 
static ON_SHA1_Hash StringHash (const ON_wString &str, ON__UINT64 &byte_count)
 
static ON_SHA1_Hash StringHash (const wchar_t *str, size_t str_length, ON__UINT64 &byte_count)
 
static ON_SHA1_Hash StringHash (const wchar_t *null_terminated_string)
 
static ON_SHA1_Hash StringHash (const ON_String &str, ON__UINT64 &byte_count)
 
static ON_SHA1_Hash StringHash (const char *str, size_t str_length, ON__UINT64 &byte_count)
 
static ON_SHA1_Hash StringHash (const char *null_terminated_string)
 

Public Attributes

ON__UINT8 m_digest [20]
 

Static Public Attributes

static const ON_SHA1_Hash EmptyContentHash
 
static const ON_SHA1_Hash ZeroDigest
 

Constructor & Destructor Documentation

◆ ON_SHA1_Hash() [1/2]

ON_SHA1_Hash::ON_SHA1_Hash ( )

The default constructor creates a zero digest sha1 hash.

◆ ~ON_SHA1_Hash()

ON_SHA1_Hash::~ON_SHA1_Hash ( )
default

◆ ON_SHA1_Hash() [2/2]

ON_SHA1_Hash::ON_SHA1_Hash ( const ON_SHA1_Hash )
default

Member Function Documentation

◆ BufferContentHash()

static ON_SHA1_Hash ON_SHA1_Hash::BufferContentHash ( const void *  buffer,
size_t  sizeof_buffer 
)
static
Parameters
buffer[in]
sizeof_buffer[in] number of bytes in buffer
Returns
SHA1-1 hash of the buffer.

◆ Compare()

static int ON_SHA1_Hash::Compare ( const ON_SHA1_Hash a,
const ON_SHA1_Hash b 
)
static

◆ Dump()

void ON_SHA1_Hash::Dump ( class ON_TextLog text_log) const

◆ FileContentHash() [1/3]

static ON_SHA1_Hash ON_SHA1_Hash::FileContentHash ( const wchar_t *  file_name,
ON__UINT64 &  sizeof_file 
)
static
Parameters
file_name[in] Name of file
sizeof_file[out] number of bytes in file
Returns
SHA1-1 hash of the buffer.

◆ FileContentHash() [2/3]

static ON_SHA1_Hash ON_SHA1_Hash::FileContentHash ( const char *  file_name,
ON__UINT64 &  sizeof_file 
)
static

◆ FileContentHash() [3/3]

static ON_SHA1_Hash ON_SHA1_Hash::FileContentHash ( FILE *  file,
ON__UINT64 &  sizeof_file 
)
static
Parameters
file[in] File stream from ON_FileStream::Open(...,L"rb");
sizeof_file[out] number of bytes in file
Returns
SHA1-1 hash of the file stream from the current offset to the end of the file.

◆ FileSystemPathHash() [1/4]

static ON_SHA1_Hash ON_SHA1_Hash::FileSystemPathHash ( const wchar_t *  path)
static

Return a hash of the file system path that is independent of the size of wchar_t, constant across platforms, and constant across varations in the way the path is formatted.

Parameters
path[in] File system path to a directory or file.
Returns

SHA1-1 hash of the buffer.

This function uses the value of ON_FileSystemPath::PlatformPathIgnoreCase() to determine if case should be ignored. Use the version with a bIgnoreCase parameter if you want to explicitly control this decision.

These file system paths have identical values of FileSystemPathHash().
/x/y/z/name.ext \x\y\z\name.ext
/x//y//z/name.ext
/x/y/a/b/c/../../../z/name.ext
/X/Y/Z/NAME.EXT (When ON_ComparePathIgnoreCase() is true)

◆ FileSystemPathHash() [2/4]

static ON_SHA1_Hash ON_SHA1_Hash::FileSystemPathHash ( const char *  path)
static

◆ FileSystemPathHash() [3/4]

static ON_SHA1_Hash ON_SHA1_Hash::FileSystemPathHash ( const wchar_t *  path,
bool  bIgnoreCase 
)
static

◆ FileSystemPathHash() [4/4]

static ON_SHA1_Hash ON_SHA1_Hash::FileSystemPathHash ( const char *  path,
bool  bIgnoreCase 
)
static

◆ IsEmptyContentHash()

bool ON_SHA1_Hash::IsEmptyContentHash ( ) const
Returns
True if this and ON_SHA1_Hash::EmptyContentHash have identical digest values.

◆ IsZeroDigentOrEmptyContentHash()

bool ON_SHA1_Hash::IsZeroDigentOrEmptyContentHash ( ) const

◆ IsZeroDigest()

bool ON_SHA1_Hash::IsZeroDigest ( ) const
Returns
True if this and ON_SHA1_Hash::ZeroDigest have identical digest values.

◆ operator=()

ON_SHA1_Hash& ON_SHA1_Hash::operator= ( const ON_SHA1_Hash )
default

◆ Read()

bool ON_SHA1_Hash::Read ( class ON_BinaryArchive archive)

◆ StringHash() [1/6]

static ON_SHA1_Hash ON_SHA1_Hash::StringHash ( const ON_wString str,
ON__UINT64 &  byte_count 
)
static
Parameters
str[in] string
byte_count[out] number of bytes in UTF-8 encoding of the string.
Returns
SHA1-1 hash of the UTF-8 encoding of the string. (Platforms and endian independent.)

◆ StringHash() [2/6]

static ON_SHA1_Hash ON_SHA1_Hash::StringHash ( const wchar_t *  str,
size_t  str_length,
ON__UINT64 &  byte_count 
)
static

◆ StringHash() [3/6]

static ON_SHA1_Hash ON_SHA1_Hash::StringHash ( const wchar_t *  null_terminated_string)
static

◆ StringHash() [4/6]

static ON_SHA1_Hash ON_SHA1_Hash::StringHash ( const ON_String str,
ON__UINT64 &  byte_count 
)
static
Parameters
str[in]
byte_count[out] number of bytes in the string.
Returns
SHA1-1 hash of the UTF-8 encoding of the string. (Platforms and endian independent.)

◆ StringHash() [5/6]

static ON_SHA1_Hash ON_SHA1_Hash::StringHash ( const char *  str,
size_t  str_length,
ON__UINT64 &  byte_count 
)
static

◆ StringHash() [6/6]

static ON_SHA1_Hash ON_SHA1_Hash::StringHash ( const char *  null_terminated_string)
static

◆ ToString()

const ON_wString ON_SHA1_Hash::ToString ( bool  bUpperCaseHexadecimalDigits) const
Parameters
bUpperCaseHexadecimalDigits[in]
falseuse 0-9, a-f
trueuse 0-9, A-F
Returns
The SHA-1 hash value as a 40 hexadecimal digits. The first digit in the string is the hexadecimal value of m_digest[0].

◆ ToUTF8String()

const ON_String ON_SHA1_Hash::ToUTF8String ( bool  bUpperCaseHexadecimalDigits) const
Parameters
bUpperCaseHexadecimalDigits[in]
falseuse 0-9, a-f
trueuse 0-9, A-F
Returns
The SHA-1 hash value as a 40 hexadecimal digits. The first digit in the string is the hexadecimal value of m_digest[0].

◆ Write()

bool ON_SHA1_Hash::Write ( class ON_BinaryArchive archive) const

Member Data Documentation

◆ EmptyContentHash

const ON_SHA1_Hash ON_SHA1_Hash::EmptyContentHash
static

◆ m_digest

ON__UINT8 ON_SHA1_Hash::m_digest[20]

◆ ZeroDigest

const ON_SHA1_Hash ON_SHA1_Hash::ZeroDigest
static