NDEVR
API Documentation
PasswordString

When passwords are used inside the NDEVR engine, we don't want them logged or visible. More...

Public Types

enum class  Strength {
  e_very_weak , e_weak , e_moderate , e_strong ,
  e_very_strong
}
 Enumeration representing the strength level of a password. More...

Public Member Functions

 PasswordString ()
 Creates an empty password string.
char * begin ()
 Returns a mutable pointer to the beginning of the encoded password data.
const char * begin () const
 Returns a const pointer to the beginning of the encoded password data.
void clear ()
 Clears the encoded password data.
String decode () const
 Decodes using the system default key which will only be valid for this software session.
String decode (const StringView &key) const
 Decodes using a specific key, in case passwords should be retrievable across sessions.
bool isEmpty ()
 Checks whether the encoded password is empty.
bool operator!= (const PasswordString &passcode) const
 Checks whether two password strings are not equal.
bool operator== (const PasswordString &passcode) const
 Checks whether two password strings are equal.
Strength passwordStrength (const StringView &key) const
 Evaluates the strength of the decoded password.
uint04 size () const
 Returns the size of the encoded password string.
void swapEncoding (const StringView &current_key, const StringView &new_key)
 Changes the encoding from one key to another.

Static Public Member Functions

static PasswordString Encode (const StringView &input)
 Encodes using the session default key which will only be valid for this software session.
static PasswordString Encode (const StringView &input, const StringView &key)
 Encodes using a specific key, in case passwords should be retrievable across sessions.
static PasswordString FromString (const StringView &value)
 Takes the value without doing any encoding or decoding.
static PasswordString RAW (const StringView &value)
 Takes the value without doing any encoding or decoding.

Detailed Description

When passwords are used inside the NDEVR engine, we don't want them logged or visible.


Passwords should be placed into this struct immediately on user input.

Warning
this class is designed to obfuscate strings, and is not made to be a strong password protection system.
See also
String

Definition at line 15 of file PasswordString.h.

Member Enumeration Documentation

◆ Strength

enum class PasswordString::Strength
strong

Enumeration representing the strength level of a password.

Enumerator
e_very_weak 

Password is very weak and easily guessable.

e_weak 

Password is weak and offers minimal security.

e_moderate 

Password has moderate strength.

e_strong 

Password is strong and reasonably secure.

e_very_strong 

Password is very strong and highly secure.

Definition at line 21 of file PasswordString.h.

Member Function Documentation

◆ begin() [1/2]

char * PasswordString::begin ( )
inline

Returns a mutable pointer to the beginning of the encoded password data.

Returns
A pointer to the first character of the encoded password.

Definition at line 39 of file PasswordString.h.

◆ begin() [2/2]

const char * PasswordString::begin ( ) const
inline

Returns a const pointer to the beginning of the encoded password data.

Returns
A const pointer to the first character of the encoded password.

Definition at line 34 of file PasswordString.h.

◆ decode() [1/2]

String PasswordString::decode ( ) const

Decodes using the system default key which will only be valid for this software session.

Ergo, you can't decode something from a previous session.

◆ decode() [2/2]

String PasswordString::decode ( const StringView & key) const

Decodes using a specific key, in case passwords should be retrievable across sessions.

Parameters
[in]keyThe current key used to decode the password. If empty, decode() will be called.

◆ Encode() [1/2]

PasswordString PasswordString::Encode ( const StringView & input)
static

Encodes using the session default key which will only be valid for this software session.

Parameters
[in]inputThe input password that will be encoded
Returns
the encoded version of the input string.

References PasswordString().

◆ Encode() [2/2]

PasswordString PasswordString::Encode ( const StringView & input,
const StringView & key )
static

Encodes using a specific key, in case passwords should be retrievable across sessions.

Parameters
[in]inputThe input password that will be encoded
[in]keyIf empty, the session default key will be used.
Returns
the encoded version of the input string.

References PasswordString().

◆ FromString()

PasswordString PasswordString::FromString ( const StringView & value)
static

Takes the value without doing any encoding or decoding.

Parameters
[in]valuethe raw, password encoded string.

References PasswordString().

◆ isEmpty()

bool PasswordString::isEmpty ( )
inline

Checks whether the encoded password is empty.

Returns
True if the password contains no data, false otherwise.

Definition at line 53 of file PasswordString.h.

◆ operator!=()

bool PasswordString::operator!= ( const PasswordString & passcode) const

Checks whether two password strings are not equal.

Parameters
[in]passcodeThe other PasswordString to compare against.
Returns
True if the passwords are not equal, false otherwise.

References PasswordString().

◆ operator==()

bool PasswordString::operator== ( const PasswordString & passcode) const

Checks whether two password strings are equal.

Parameters
[in]passcodeThe other PasswordString to compare against.
Returns
True if the passwords are equal, false otherwise.

References PasswordString().

◆ passwordStrength()

Strength PasswordString::passwordStrength ( const StringView & key) const

Evaluates the strength of the decoded password.

Parameters
[in]keyThe key used to decode the password before evaluating strength.
Returns
The strength level of the password.

◆ RAW()

PasswordString PasswordString::RAW ( const StringView & value)
static

Takes the value without doing any encoding or decoding.

Parameters
[in]valuethe raw, password encoded string.

References PasswordString().

◆ size()

uint04 PasswordString::size ( ) const
inline

Returns the size of the encoded password string.

Returns
The number of characters in the encoded password.

Definition at line 44 of file PasswordString.h.

◆ swapEncoding()

void PasswordString::swapEncoding ( const StringView & current_key,
const StringView & new_key )

Changes the encoding from one key to another.

Useful for converting passwords to a usable form without ever revealing the raw password.

Parameters
[in]current_keyThe current key used to encode the password. If empty, the session default will be used
[in]new_keyThe key to use as the new encoding. If empty, the session default will be used.

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