32 const std::string& user,
33 const std::string& pass,
38 user.c_str(), user.length(),
39 pass.c_str(), pass.length(),
44 const char* user,
size_t userLen,
45 const char* pass,
size_t passLen,
49 std::vector< uint16 > username, password;
51 std::back_inserter( username ) );
53 std::back_inserter( password ) );
56 std::transform( username.begin(), username.end(),
57 username.begin(), ::tolower );
60 const size_t frontIndex =
61 std::find_if( username.begin(), username.end(),
62 std::not1( std::ptr_fun( ::isspace ) ) )
65 const size_t backIndex =
66 std::find_if( username.rbegin(), username.rend(),
67 std::not1( std::ptr_fun( ::isspace ) ) )
71 username.erase( username.begin(),
72 username.begin() + frontIndex );
73 username.erase( username.end() - backIndex,
81 const std::vector< uint16 >& user,
82 const std::vector< uint16 >& pass,
87 &user[0], user.size(),
88 &pass[0], pass.size(),
93 const uint16* user,
size_t userLen,
94 const uint16* pass,
size_t passLen,
98 const uint8* _user =
reinterpret_cast< const uint8*
>( user );
99 size_t _userLen = userLen *
sizeof(
uint16 );
100 const uint8* _pass =
reinterpret_cast< const uint8*
>( pass );
101 size_t _passLen = passLen *
sizeof(
uint16 );
113 for(
size_t i = 0; i < 1000; ++i )
127 reinterpret_cast< char* >( digest ),
static void sha_final(unsigned char digest[20], SHAobject *sha_info)
static void sha_digest(SHAobject *self, uint8 *digest)
std::u16string utf8to16(std::string &str)
static bool GeneratePassHash(const std::string &user, const std::string &pass, std::string &hash)
Generates a SHA-1 hash from a username and a password.
static void sha_update(SHAobject *sha_info, const SHA_BYTE *buffer, int count)
static void sha_init(SHAobject *sha_info)