Skip to content
Snippets Groups Projects
player.hpp 698 B
#ifndef _PLAYER_H
#define _PLAYER_H
#include "game.hpp"
#include <botan/argon2.h>
#include <botan/system_rng.h>

class Player {
  std::string username;
  std::string hashedPw;

  GameState state;

public:
  Player(const std::string &name, const std::string &pw) : state() {
    Botan::System_RNG rng;

    hashedPw = Botan::argon2_generate_pwhash(pw.c_str(), sizeof(pw.c_str()),
                                             rng, 1, 4000, 1);
  }

  bool authenticate(const std::string &pw) {
    return Botan::argon2_check_pwhash(pw.c_str(), pw.size(), hashedPw);
  }
  std::array<GameState::matchType, WORD_LENGTH>
  guess(const std::string &guess) {
    return state.guess(guess);
  }
};

#endif