MySQL 8.3.0
Source Code Documentation
digest.h
Go to the documentation of this file.
1#ifndef DIGEST_INCLUDED
2#define DIGEST_INCLUDED
3/* Copyright (c) 2017, 2023, Oracle and/or its affiliates.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License, version 2.0,
7 as published by the Free Software Foundation.
8
9 This program is also distributed with certain software (including
10 but not limited to OpenSSL) that is licensed under separate terms,
11 as designated in a particular file or component or in included license
12 documentation. The authors of MySQL hereby grant you an additional
13 permission to link the program and your derivative works with the
14 separately licensed software that they have included with MySQL.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License, version 2.0, for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
24
25/**
26 @file storage/perfschema/digest.h
27 Constants and functionality that facilitate working with digests.
28*/
29
30/**
31 Write SHA-256 hash value in a string to be used
32 as DIGEST for the statement.
33*/
34#define DIGEST_HASH_TO_STRING(_hash, _str) \
35 (void)sprintf(_str, \
36 "%02x%02x%02x%02x%02x%02x%02x%02x" \
37 "%02x%02x%02x%02x%02x%02x%02x%02x" \
38 "%02x%02x%02x%02x%02x%02x%02x%02x" \
39 "%02x%02x%02x%02x%02x%02x%02x%02x", \
40 _hash[0], _hash[1], _hash[2], _hash[3], _hash[4], _hash[5], \
41 _hash[6], _hash[7], _hash[8], _hash[9], _hash[10], _hash[11], \
42 _hash[12], _hash[13], _hash[14], _hash[15], _hash[16], \
43 _hash[17], _hash[18], _hash[19], _hash[20], _hash[21], \
44 _hash[22], _hash[23], _hash[24], _hash[25], _hash[26], \
45 _hash[27], _hash[28], _hash[29], _hash[30], _hash[31])
46
47/// SHA-256 = 32 bytes of binary = 64 printable characters.
48#define DIGEST_HASH_TO_STRING_LENGTH 64
49
50#endif // DIGEST_INCLUDED