Remove default hash algorithm from the new hash functions
[libi2ncommon] / src / crypto.hxx
CommitLineData
69d568dd
TC
1/*
2The software in this package is distributed under the GNU General
3Public License version 2 (with a special exception described below).
4
5A copy of GNU General Public License (GPL) is included in this distribution,
6in the file COPYING.GPL.
7
8As a special exception, if other files instantiate templates or use macros
9or inline functions from this file, or you compile this file and link it
10with other works to produce a work based on this file, this file
11does not by itself cause the resulting work to be covered
12by the GNU General Public License.
13
14However the source code for this file must still be made available
15in accordance with section (3) of the GNU General Public License.
16
17This exception does not invalidate any other reasons why a work based
18on this file might be covered by the GNU General Public License.
19*/
20/**
21 Hashing functions based upon openssl.
22
23 @copyright Intra2net AG
24*/
25
26#ifndef CRYPTO_HXX
27#define CRYPTO_HXX
28
29
30#if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
31using namespace std;
32#endif
33
34#include <openssl/evp.h>
35#include <boost/shared_array.hpp>
36#include <boost/shared_ptr.hpp>
37
38namespace I2n {
39
40enum algorithm { NONE=0, MD5=1, SHA1=2, SHA256=8, SHA384=9, SHA512=10 };
41
42// output: hex encoded hash
2bf8e5a0 43string hash_data(string data, algorithm algo);
69d568dd
TC
44
45// output: raw binary hash
2bf8e5a0 46string hash_data_raw(string data, algorithm algo);
69d568dd
TC
47
48// hash data in 64kB blocks
2bf8e5a0 49string hash_file(string filename, algorithm algo);
69d568dd
TC
50
51string encode_hex(string data);
52
53string encode_hex(char *data, unsigned int size);
54
55typedef boost::shared_array<char> char_arr;
56
57typedef boost::shared_array<unsigned char> uchar_arr;
58
59typedef boost::shared_ptr<EVP_MD_CTX> EVP_MD_CTX_Ptr;
60}; // eo I2n namespace
61
62#endif /* [CRYPTO_HXX] */