MCPcopy Create free account
hub / github.com/Kitware/CMake / cmCryptoHash

Class cmCryptoHash

Source/cmCryptoHash.h:18–103  ·  view source on GitHub ↗

* @brief Abstract base class for cryptographic hash generators */

Source from the content-addressed store, hash-verified

16 * @brief Abstract base class for cryptographic hash generators
17 */
18class cmCryptoHash
19{
20public:
21 enum Algo
22 {
23 AlgoMD5,
24 AlgoSHA1,
25 AlgoSHA224,
26 AlgoSHA256,
27 AlgoSHA384,
28 AlgoSHA512,
29 AlgoSHA3_224,
30 AlgoSHA3_256,
31 AlgoSHA3_384,
32 AlgoSHA3_512
33 };
34
35 cmCryptoHash(Algo algo);
36 ~cmCryptoHash();
37
38 cmCryptoHash(cmCryptoHash const&) = delete;
39 cmCryptoHash& operator=(cmCryptoHash const&) = delete;
40
41 /// @brief Returns a new hash generator of the requested type
42 /// @arg algo Hash type name. Supported hash types are
43 /// MD5, SHA1, SHA224, SHA256, SHA384, SHA512,
44 /// SHA3_224, SHA3_256, SHA3_384, SHA3_512
45 /// @return A valid auto pointer if algo is supported or
46 /// an invalid/NULL pointer otherwise
47 static std::unique_ptr<cmCryptoHash> New(cm::string_view algo);
48
49 /// @brief Converts a hex character to its binary value (4 bits)
50 /// @arg input Hex character [0-9a-fA-F].
51 /// @arg output Binary value of the input character (4 bits)
52 /// @return True if input was a valid hex character
53 static bool IntFromHexDigit(char input, char& output);
54
55 /// @brief Converts a byte hash to a sequence of hex character pairs
56 static std::string ByteHashToString(std::vector<unsigned char> const& hash);
57
58 /// @brief Calculates a binary hash from string input data
59 /// @return Binary hash vector
60 std::vector<unsigned char> ByteHashString(cm::string_view input);
61
62 /// @brief Calculates a binary hash from stream content
63 /// @see ByteHashString()
64 /// @return Non empty binary hash vector if the stream was read successfully.
65 /// An empty vector otherwise.
66 std::vector<unsigned char> ByteHashStream(std::istream& sin);
67
68 /// @brief Calculates a binary hash from file content
69 /// @see ByteHashString()
70 /// @return Non empty binary hash vector if the file was read successfully.
71 /// An empty vector otherwise.
72 std::vector<unsigned char> ByteHashFile(std::string const& file);
73
74 /// @brief Calculates a hash string from string input data
75 /// @return Sequence of hex characters pairs for each byte of the binary hash

Callers 4

getMethod · 0.70
WriteJsonFileMethod · 0.70
runTestFunction · 0.50
testProtocolWithPipesFunction · 0.50

Calls

no outgoing calls

Tested by 2

runTestFunction · 0.40
testProtocolWithPipesFunction · 0.40

Used in the wild real call sites across dependent graphs

searching dependent graphs…