summaryrefslogtreecommitdiff
path: root/src/user.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/user.cpp')
-rw-r--r--src/user.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/user.cpp b/src/user.cpp
index 3541eba..8156ff0 100644
--- a/src/user.cpp
+++ b/src/user.cpp
@@ -2,7 +2,6 @@
#include "user.hpp"
#include "strusCms.hpp"
#include "captcha.hpp"
-#include "sha1.hpp"
#include <cppcms/url_dispatcher.h>
#include <cppcms/url_mapper.h>
@@ -10,6 +9,10 @@
#include <cppcms/session_interface.h>
#include <booster/posix_time.h>
+#include "cryptopp/sha.h"
+#include "cryptopp/filters.h"
+#include "cryptopp/hex.h"
+
#include <cstdlib>
#include <sstream>
#include <iomanip>
@@ -179,18 +182,18 @@ std::string generate_token( )
std::string compute_token_hash( const std::string user, const std::string token )
{
- sha::SHA1 sha;
- unsigned int res[5];
- sha.Reset( );
- sha << user.c_str( ) << token.c_str( );
-
+ CryptoPP::SHA256 sha;
std::ostringstream oss;
- for( int i = 0; i < 5; i++ ) {
- oss << std::uppercase << std::hex << std::setw( 8 ) << std::setfill( '0' ) << res[i];
- if( i < 4 ) oss << ' ';
- }
+ oss << user << token;
+ std::string source = oss.str( );
+ std::string value;
+
+ CryptoPP::StringSource ss( source, true,
+ new CryptoPP::HashFilter( sha,
+ new CryptoPP::HexEncoder(
+ new CryptoPP::StringSink( value ) ) ) );
- return oss.str( );
+ return value;
}
}