The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
hash.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2016 by Thomas Baumhauer <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
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 as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #ifndef HASH_HPP_INCLUDED
16 #define HASH_HPP_INCLUDED
17 
18 #include <array>
19 #include <cstdint>
20 #include <string>
21 
22 namespace util {
23 
24 /**
25  * Returns the MD5 digest for the specified input.
26  *
27  * @note The returned value points to a fixed-size 16 bytes array representing
28  * the raw MD5 value, not a null-terminated string. Use encode_hash if
29  * you need the text representation instead.
30  */
31 std::array<uint8_t, 16> md5(const std::string& input);
32 int get_iteration_count(const std::string& hash);
33 std::string get_salt(const std::string& hash);
34 bool is_valid_hash(const std::string& hash);
35 std::string encode_hash(const std::array<uint8_t, 16>& input);
36 std::string create_hash(const std::string& password, const std::string& salt, int iteration_count =10);
37 
38 } // namespace util
39 
40 #endif // HASH_HPP_INCLUDED
GLenum GLenum GLenum input
Definition: glew.h:10668
std::array< uint8_t, 16 > md5(const std::string &input)
Returns the MD5 digest for the specified input.
Definition: hash.cpp:26
std::string get_salt(const std::string &hash)
Definition: hash.cpp:37
std::string create_hash(const std::string &password, const std::string &salt, int iteration_count)
Definition: hash.cpp:74
bool is_valid_hash(const std::string &hash)
Definition: hash.cpp:41
std::string encode_hash(const std::array< uint8_t, 16 > &input)
Definition: hash.cpp:51
GLsizei const GLcharARB ** string
Definition: glew.h:4503
int get_iteration_count(const std::string &hash)
Definition: hash.cpp:33