mirror of
https://github.com/LCEMP/LCEMP.git
synced 2026-04-23 07:24:14 +00:00
33 lines
742 B
C++
33 lines
742 B
C++
#include "stdafx.h"
|
|
#include <xhash>
|
|
#include <functional>
|
|
|
|
#include "Hasher.h"
|
|
|
|
Hasher::Hasher(wstring &salt)
|
|
{
|
|
this->salt = salt;
|
|
}
|
|
|
|
wstring Hasher::getHash(wstring &name)
|
|
{
|
|
// 4J Stu - Removed try/catch
|
|
//try {
|
|
wstring s = wstring( salt ).append( name );
|
|
//MessageDigest m;
|
|
//m = MessageDigest.getInstance("MD5");
|
|
//m.update(s.getBytes(), 0, s.length());
|
|
//return new BigInteger(1, m.digest()).toString(16);
|
|
|
|
// TODO 4J Stu - Will this hash us with the same distribution as the MD5?
|
|
#if !defined(_MSC_VER) || _MSC_VER >= 1900
|
|
return _toString( std::hash<wstring>{}( s ) );
|
|
#else
|
|
return _toString( stdext::hash_value( s ) );
|
|
#endif
|
|
//}
|
|
//catch (NoSuchAlgorithmException e)
|
|
//{
|
|
// throw new RuntimeException(e);
|
|
//}
|
|
} |