Electroneum
tools::password_container Class Reference

#include <password.h>

Collaboration diagram for tools::password_container:

Public Member Functions

 password_container () noexcept
 Empty password. More...
 
 password_container (std::string &&password) noexcept
 password is used as password More...
 
 password_container (const epee::wipeable_string &password) noexcept
 
 password_container (const password_container &)=delete
 
 password_container (password_container &&rhs)=default
 
 ~password_container () noexcept
 Wipes internal password. More...
 
password_containeroperator= (const password_container &)=delete
 
password_containeroperator= (password_container &&)=default
 
const epee::wipeable_stringpassword () const noexcept
 

Static Public Member Functions

static boost::optional< password_containerprompt (bool verify, const char *mesage="Password", bool hide_input=true)
 

Static Public Attributes

static constexpr const size_t max_password_size = 1024
 
static std::atomic< boolis_prompting
 

Detailed Description

Definition at line 41 of file password.h.

Constructor & Destructor Documentation

◆ password_container() [1/5]

tools::password_container::password_container ( )
noexcept

Empty password.

Definition at line 236 of file password.cpp.

236 : m_password() {}

◆ password_container() [2/5]

tools::password_container::password_container ( std::string &&  password)
noexcept

password is used as password

Definition at line 237 of file password.cpp.

238  : m_password(std::move(password))
239  {
240  }
const T & move(const T &t)
Definition: gtest-port.h:1317
const epee::wipeable_string & password() const noexcept
Definition: password.h:66

◆ password_container() [3/5]

tools::password_container::password_container ( const epee::wipeable_string password)
noexcept

Definition at line 241 of file password.cpp.

242  : m_password(password)
243  {
244  }
const epee::wipeable_string & password() const noexcept
Definition: password.h:66

◆ password_container() [4/5]

tools::password_container::password_container ( const password_container )
delete

◆ password_container() [5/5]

tools::password_container::password_container ( password_container &&  rhs)
default

◆ ~password_container()

tools::password_container::~password_container ( )
noexcept

Wipes internal password.

Definition at line 246 of file password.cpp.

247  {
248  m_password.clear();
249  }
Here is the call graph for this function:

Member Function Documentation

◆ operator=() [1/2]

password_container& tools::password_container::operator= ( const password_container )
delete

◆ operator=() [2/2]

password_container& tools::password_container::operator= ( password_container &&  )
default

◆ password()

const epee::wipeable_string& tools::password_container::password ( ) const
inlinenoexcept

Definition at line 66 of file password.h.

66 { return m_password; }

◆ prompt()

boost::optional< password_container > tools::password_container::prompt ( bool  verify,
const char *  mesage = "Password",
bool  hide_input = true 
)
static
Returns
A password from stdin TTY prompt or std::cin pipe.

Definition at line 253 of file password.cpp.

254  {
255  is_prompting = true;
256  password_container pass1{};
257  password_container pass2{};
258  if (is_cin_tty() ? read_from_tty(verify, message, hide_input, pass1.m_password, pass2.m_password) : read_from_file(pass1.m_password))
259  {
260  is_prompting = false;
261  return {std::move(pass1)};
262  }
263 
264  is_prompting = false;
265  return boost::none;
266  }
static std::atomic< bool > is_prompting
Definition: password.h:55
password_container() noexcept
Empty password.
Definition: password.cpp:236
std::string message("Message requiring signing")
const T & move(const T &t)
Definition: gtest-port.h:1317
Here is the call graph for this function:

Member Data Documentation

◆ is_prompting

std::atomic< bool > tools::password_container::is_prompting
static

Definition at line 55 of file password.h.

◆ max_password_size

constexpr const size_t tools::password_container::max_password_size = 1024
static

Definition at line 44 of file password.h.


The documentation for this class was generated from the following files: