Rhino C++ API  7.18
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
ON_SHA1_Hash Class Reference

#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 IsSet () const
 
bool IsZeroDigentOrEmptyContentHash () const
 
bool IsZeroDigest () const
 
bool IsZeroDigestOrEmptyContentHash () const
 
ON_SHA1_Hashoperator= (const ON_SHA1_Hash &)=default
 
bool Read (class ON_BinaryArchive &archive)
 
const ON_wString ToString (bool bUpperCaseHexadecimalDigits) const
 
const ON_wString ToStringEx (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 char *file_name, ON__UINT64 &sizeof_file)
 
static ON_SHA1_Hash FileContentHash (const wchar_t *file_name, ON__UINT64 &sizeof_file)
 
static ON_SHA1_Hash FileContentHash (FILE *file, ON__UINT64 &sizeof_file)
 
static ON_SHA1_Hash FileSystemPathHash (const char *path)
 
static ON_SHA1_Hash FileSystemPathHash (const char *path, bool bIgnoreCase)
 
static ON_SHA1_Hash FileSystemPathHash (const wchar_t *path)
 
static ON_SHA1_Hash FileSystemPathHash (const wchar_t *path, bool bIgnoreCase)
 
static const ON_SHA1_Hash FromString (const ON_wString string_to_parse, bool bParseLeasingSpaces, bool bParseInteriorSpace, bool bParseInteriorHyphen, ON_SHA1_Hash failure_return_value)
 
static ON_SHA1_Hash StringHash (const char *null_terminated_string)
 
static ON_SHA1_Hash StringHash (const char *str, size_t str_length, ON__UINT64 &byte_count)
 
static ON_SHA1_Hash StringHash (const ON_String &str, ON__UINT64 &byte_count)
 
static ON_SHA1_Hash StringHash (const ON_wString &str, ON__UINT64 &byte_count)
 
static ON_SHA1_Hash StringHash (const wchar_t *null_terminated_string)
 
static ON_SHA1_Hash StringHash (const wchar_t *str, size_t str_length, ON__UINT64 &byte_count)
 

Public Attributes

ON__UINT8 m_digest [20]
 

Static Public Attributes

static const ON_SHA1_Hash EmptyContentHash
 SHA-1 hash of zero bytes. More...
 
static const ON_SHA1_Hash ZeroDigest
 all digest bytes are zero More...
 

Detailed Description

/ / Copyright (c) 1993-2015 Robert McNeel & Associates. All rights reserved. / OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert / McNeel & Associates. / / THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. / ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF / MERCHANTABILITY ARE HEREBY DISCLAIMED. /
/ For complete openNURBS copyright information see http://www.opennurbs.org. / //////////////////////////////////////////////////////////////

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 char *  file_name,
ON__UINT64 sizeof_file 
)
static

◆ FileContentHash() [2/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() [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 char *  path)
static

◆ FileSystemPathHash() [2/4]

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

◆ FileSystemPathHash() [3/4]

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

Description: 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.

Example: 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)

Remarks: 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.

◆ FileSystemPathHash() [4/4]

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

◆ FromString()

static const ON_SHA1_Hash ON_SHA1_Hash::FromString ( const ON_wString  string_to_parse,
bool  bParseLeasingSpaces,
bool  bParseInteriorSpace,
bool  bParseInteriorHyphen,
ON_SHA1_Hash  failure_return_value 
)
static

Description: Parse a string of 40 hexadecimal digits to create a SHA-1 hash. Parameters: string_to_parse - [in] bParseLeadinglSpaces - [in] If true, leading space characters are parsed. Otherwise leading space characters cause parsing to fail. bParseInteriorSpace - [in] If true, interior space characters are parsed. Otherwise interior space characters cause parsing to fail. bParseInteriorHyphen - [in] If true, interior hyphen characters are parsed. Otherwise interior hyphen characters cause parsing to fail. bIgnoreInternalSpaces - [in] If true, isolated hyphens are ingored until 40 hex digits are read. bIgnoreInternalHyphens - [in] If true, leading spaces and isolated interior spacess are ingored until 40 hex digits are read. failure_return_value - [in] Value to return if string_to_parse cannot be parsed as 40 hex digits. Returns: If parsing is successful, the value of the SHA-1 hash is returned. Otherwise failure_return_value is returned.

◆ IsEmptyContentHash()

bool ON_SHA1_Hash::IsEmptyContentHash ( ) const

Returns: True if this and ON_SHA1_Hash::EmptyContentHash have identical digest values.

◆ IsSet()

bool ON_SHA1_Hash::IsSet ( ) const

Returns: True if this hash is not equal to ON_SHA1_Hash::EmptyContentHash or ON_SHA1_Hash::ZeroDigest. Remarks: ON_SHA1_Hash::EmptyContentHash is the SHA1 of hasing zero bytes and has a non zero digest. ON_SHA1_Hash::ZeroDigest is 20 bytes of zeros. Opennurbs uses ON_SHA1_Hash::ZeroDigest to indicate a SHA1 has is not initialized.

◆ IsZeroDigentOrEmptyContentHash()

bool ON_SHA1_Hash::IsZeroDigentOrEmptyContentHash ( ) const
Deprecated:
Use IsZeroDigestOrEmptyContentHash() instead. (Spelling error in this one's name.

◆ IsZeroDigest()

bool ON_SHA1_Hash::IsZeroDigest ( ) const

Returns: True if this and ON_SHA1_Hash::ZeroDigest have identical digest values.

◆ IsZeroDigestOrEmptyContentHash()

bool ON_SHA1_Hash::IsZeroDigestOrEmptyContentHash ( ) const

◆ 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 char *  null_terminated_string)
static

◆ StringHash() [2/6]

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

◆ StringHash() [3/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() [4/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() [5/6]

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

◆ StringHash() [6/6]

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

◆ ToString()

const ON_wString ON_SHA1_Hash::ToString ( bool  bUpperCaseHexadecimalDigits) const

Parameters: bUpperCaseHexadecimalDigits - [in] false - use 0-9, a-f true - use 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].

◆ ToStringEx()

const ON_wString ON_SHA1_Hash::ToStringEx ( bool  bUpperCaseHexadecimalDigits) const

Description: Same as ToString but prints EmptyContentSHA1 or ZeroSHA1 for those two special cases.

◆ ToUTF8String()

const ON_String ON_SHA1_Hash::ToUTF8String ( bool  bUpperCaseHexadecimalDigits) const

Parameters: bUpperCaseHexadecimalDigits - [in] false - use 0-9, a-f true - use 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

SHA-1 hash of zero bytes.

◆ m_digest

ON__UINT8 ON_SHA1_Hash::m_digest[20]

◆ ZeroDigest

const ON_SHA1_Hash ON_SHA1_Hash::ZeroDigest
static

all digest bytes are zero