Rhino C++ API
8.12
|
#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 | |
ON__UINT32 | CRC32 (ON__UINT32 current_remainder) const |
Calculating a SHA1 hash is faster than calculating a CRC on the same information. This function calculates the ON_CRC value of the 20 byte digest. Calculating a sha1 hash and then using CRC32(0) is an excellent and efficient way to get a high quality 4 byte CRC. More... | |
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_Hash & | operator= (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... | |
Copyright (c) 1993-2022 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.
ON_SHA1_Hash::ON_SHA1_Hash | ( | ) |
The default constructor creates a zero digest sha1 hash.
|
default |
|
default |
|
static |
Parameters: buffer - [in] sizeof_buffer - [in] number of bytes in buffer Returns: SHA1-1 hash of the buffer.
|
static |
ON__UINT32 ON_SHA1_Hash::CRC32 | ( | ON__UINT32 | current_remainder | ) | const |
Calculating a SHA1 hash is faster than calculating a CRC on the same information. This function calculates the ON_CRC value of the 20 byte digest. Calculating a sha1 hash and then using CRC32(0) is an excellent and efficient way to get a high quality 4 byte CRC.
current_remainder | Nonzero values are rare in this context. When in doubt, pass 0. |
void ON_SHA1_Hash::Dump | ( | class ON_TextLog & | text_log | ) | const |
|
static |
|
static |
Parameters: file_name - [in] Name of file sizeof_file - [out] number of bytes in file Returns: SHA1-1 hash of the buffer.
|
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.
|
static |
|
static |
|
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 variations 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.
|
static |
|
static |
Description: Parse a string of 40 hexadecimal digits to create a SHA-1 hash. Parameters: string_to_parse - [in] bParseLeadingSpaces - [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 ignored until 40 hex digits are read. bIgnoreInternalHyphens - [in] If true, leading spaces and isolated interior spaces are ignored 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.
bool ON_SHA1_Hash::IsEmptyContentHash | ( | ) | const |
Returns: True if this and ON_SHA1_Hash::EmptyContentHash have identical digest values.
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 hashing 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.
bool ON_SHA1_Hash::IsZeroDigentOrEmptyContentHash | ( | ) | const |
bool ON_SHA1_Hash::IsZeroDigest | ( | ) | const |
Returns: True if this and ON_SHA1_Hash::ZeroDigest have identical digest values.
bool ON_SHA1_Hash::IsZeroDigestOrEmptyContentHash | ( | ) | const |
|
default |
bool ON_SHA1_Hash::Read | ( | class ON_BinaryArchive & | archive | ) |
|
static |
|
static |
|
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.)
|
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.)
|
static |
|
static |
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].
const ON_wString ON_SHA1_Hash::ToStringEx | ( | bool | bUpperCaseHexadecimalDigits | ) | const |
Description: Same as ToString but prints EmptyContentSHA1 or ZeroSHA1 for those two special cases.
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].
bool ON_SHA1_Hash::Write | ( | class ON_BinaryArchive & | archive | ) | const |
|
static |
SHA-1 hash of zero bytes.
ON__UINT8 ON_SHA1_Hash::m_digest[20] |
|
static |
all digest bytes are zero