blob: 154f600bfe93bf428ffd47f0d19a1c9366fa91dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/* Include file for high-level encryption routines.
*
* (C) 2003-2012 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*/
#include "services.h"
#include "modules.h"
#include "extern.h"
/******************************************************************************/
/** Encrypt the string src into dest
* @param src The source string
* @param dest The destination strnig
*/
void enc_encrypt(const Anope::string &src, Anope::string &dest)
{
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnEncrypt, OnEncrypt(src, dest));
}
/** Decrypt the encrypted string src into dest
* @param src The encrypted string
* @param desc The destination string
* @return true on success
*/
bool enc_decrypt(const Anope::string &src, Anope::string &dest)
{
size_t pos = src.find(':');
if (pos == Anope::string::npos)
{
Log() << "Error: enc_decrypt() called with invalid password string (" << src << ")";
return false;
}
Anope::string hashm(src.begin(), src.begin() + pos);
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnDecrypt, OnDecrypt(hashm, src, dest));
if (MOD_RESULT == EVENT_ALLOW)
return true;
return false;
}
|