dfaf771f0317e162ec65ef72569cc2fb808495f7
[reactos.git] / irc / ArchBlackmann / cram_md5.cpp
1 // cram_md5.cpp
2 // This file is (C) 2004 Royce Mitchell III
3 // and released under the BSD & LGPL licenses
4
5 #include "md5.h"
6 #include "cram_md5.h"
7 #include "base64.h"
8
9 using std::string;
10
11 string cram_md5 ( const string& username, const string& password, const string& greeting )
12 {
13 string challenge = base64_decode ( greeting );
14
15 string hmac = HMAC_MD5 ( password, challenge );
16 //printf ( "(cram_md5): hmac = %s\n", hmac.c_str() );
17 string raw_response = username;
18 raw_response += " ";
19 raw_response += hmac;
20 //printf ( "(cram_md5): raw_response = %s\n", raw_response.c_str() );
21
22 return base64_encode ( raw_response );
23 }