1
0
mirror of https://github.com/anope/anope.git synced 2026-07-03 05:53:12 +02:00

Merge branch '1.9' of ssh://anope.git.sf.net/gitroot/anope/anope into 1.9

This commit is contained in:
Naram Qashat
2010-08-01 12:21:42 -04:00
3 changed files with 37 additions and 2 deletions
+11
View File
@@ -152,6 +152,11 @@ namespace Anope
*/
inline size_type length() const { return this->_string.length(); }
/**
* Resizes the string content to n characters.
*/
inline void resize(size_type n) { return this->_string.resize(n); }
/**
* Erases characters from the string.
*/
@@ -311,6 +316,12 @@ namespace Anope
* @return a vector with pointers to the messagehandlers (you can bind more than one handler to a message)
*/
extern CoreExport std::vector<Message *> FindMessage(const string &name);
/** Converts a string to hex
* @param the data to be converted
* @return a anope::string containing the hex value
*/
extern CoreExport string Hex(const string &data);
}
/** sepstream allows for splitting token seperated lists.
+3 -2
View File
@@ -138,6 +138,7 @@ class ESHA256 : public Module
Anope::string buf2;
for (int i = 0; i < 8; ++i)
UNPACK32(iv[i], reinterpret_cast<unsigned char *>(&buf[i << 2]));
buf[32] = '\0';
b64_encode(buf, buf2);
return buf2;
}
@@ -262,7 +263,7 @@ class ESHA256 : public Module
EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest)
{
char digest[SHA256_DIGEST_SIZE];
char digest[SHA256_DIGEST_SIZE+1];
Anope::string cpass;
SHA256Context ctx;
std::stringstream buf;
@@ -275,7 +276,7 @@ class ESHA256 : public Module
SHA256Init(&ctx);
SHA256Update(&ctx, reinterpret_cast<const unsigned char *>(src.c_str()), src.length());
SHA256Final(&ctx, reinterpret_cast<unsigned char *>(digest));
digest[SHA256_DIGEST_SIZE] = '\0';
b64_encode(digest, cpass);
buf << "sha256:" << cpass << ":" << GetIVString();
Alog(LOG_DEBUG_2) << "(enc_sha256) hashed password from [" << src << "] to [" << buf.str() << " ]";
+23
View File
@@ -1296,3 +1296,26 @@ bool str_is_cidr(const Anope::string &str, uint32 &ip, uint32 &mask, Anope::stri
return true;
}
/********************************************************************************/
/** Converts a string to hex
* @param the data to be converted
* @return a anope::string containing the hex value
*/
Anope::string Anope::Hex(const Anope::string &data)
{
const char hextable[] = "0123456789abcdef";
int l = data.length();
Anope::string rv;
for(int i=0; i < l; i++)
{
unsigned char c = data[i];
rv += hextable[c >> 4];
rv += hextable[c & 0xF];
}
return rv;
}