mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
Added the ability to change your password (via pause menu)
--HG-- extra : rebase_source : e8ec407f60711d42d33be4811b2880088f617b5b
This commit is contained in:
parent
e0329a3cae
commit
a8a3271470
14 changed files with 457 additions and 28 deletions
|
@ -23,6 +23,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
|
||||
#include "utility.h"
|
||||
#include "gettime.h"
|
||||
#include "sha1.h"
|
||||
#include "base64.h"
|
||||
|
||||
TimeTaker::TimeTaker(const char *name, u32 *result)
|
||||
{
|
||||
|
@ -217,3 +219,24 @@ bool isBlockInSight(v3s16 blockpos_b, v3f camera_pos, v3f camera_dir, f32 range,
|
|||
return true;
|
||||
}
|
||||
|
||||
// Get an sha-1 hash of the player's name combined with
|
||||
// the password entered. That's what the server uses as
|
||||
// their password. (Exception : if the password field is
|
||||
// blank, we send a blank password - this is for backwards
|
||||
// compatibility with password-less players).
|
||||
std::string translatePassword(std::string playername, std::wstring password)
|
||||
{
|
||||
if(password.length() == 0)
|
||||
return "";
|
||||
|
||||
std::string slt=playername + wide_to_narrow(password);
|
||||
SHA1 *sha1 = new SHA1();
|
||||
sha1->addBytes(slt.c_str(), slt.length());
|
||||
unsigned char *digest = sha1->getDigest();
|
||||
std::string pwd = base64_encode(digest, 20);
|
||||
free(digest);
|
||||
return pwd;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue