DiceKeys Seeded Cryptography Library
Password Class Reference

A secret derived from a seed string and set of options in JSON Format for Recipes. More...

#include <password.hpp>

Public Member Functions

 Password (const Password &other)
 Construct this object as a copy of another object. More...
 
 Password (const std::string &password, const std::string &recipe={})
 
const std::string toJson (int indent=-1, const char indent_char=' ') const
 Serialize this object to a JSON-formatted string. More...
 
const SodiumBuffer toSerializedBinaryForm () const
 Serialize to byte array as a list of: (secretBytes, recipe) More...
 

Static Public Member Functions

static Password deriveFromSeedAndWordList (const std::string &seedString, const std::string &recipe, const std::string &wordListAsSingleString)
 Derive a secret from a seed secret and a set of recipe in JSON Format for Recipes. More...
 
static Password deriveFromSeed (const std::string &seedString, const std::string &recipe)
 
static Password fromSerializedBinaryForm (const SodiumBuffer &serializedBinaryForm)
 Deserialize from a byte array stored as a list of: (secretBytes, recipe) More...
 
static Password fromJson (const std::string &seedAsJson)
 Construct (reconstitute) a Password from its JSON representation. More...
 

Public Attributes

const std::string password
 The binary representation of the password.
 
const std::string recipe
 A string in JSON Format for Recipes string which specifies how the constructor will derive the secretBytes from the original secret seed.
 

Detailed Description

A secret derived from a seed string and set of options in JSON Format for Recipes.

Because the secret is derived using a one-way function, its value does not reveal the secret seed used to derive it. Rather, clients can use this secret knowing that, if lost, it can be re-derived from the same seed and recipe that were first used to derive it.

Constructor & Destructor Documentation

◆ Password() [1/2]

Password::Password ( const Password other)

Construct this object as a copy of another object.

Parameters
otherThe Password to copy into this new object

◆ Password() [2/2]

Password::Password ( const std::string &  password,
const std::string &  recipe = {} 
)

Construct a secret from its two fields: the secretBytes and the recipe.

Parameters
secretBytesThe derived secret.
passwordThe derived password
recipeThe recipe in JSON Format for Recipes.

Member Function Documentation

◆ deriveFromSeedAndWordList()

Password Password::deriveFromSeedAndWordList ( const std::string &  seedString,
const std::string &  recipe,
const std::string &  wordListAsSingleString 
)
static

Derive a secret from a seed secret and a set of recipe in JSON Format for Recipes.

Parameters
seedStringThe secret seed string from which this secret should be derived. Once the secret is derived, you won't need the secretSeedBytes again unless you need to re-derive this secret.
recipeThe recipe in JSON Format for Recipes.
wordListAsSingleStringThe word list to use to generate the password, with words separated by any number of non-alphabetic characters. This allows word lists to be tab-delimited, comma-delimited, line-delimited, or any combination thereof.

◆ fromJson()

Password Password::fromJson ( const std::string &  seedAsJson)
static

Construct (reconstitute) a Password from its JSON representation.

Parameters
seedAsJsonA Password serialized in JSON format via a previous call to toJson.

◆ fromSerializedBinaryForm()

Password Password::fromSerializedBinaryForm ( const SodiumBuffer serializedBinaryForm)
static

Deserialize from a byte array stored as a list of: (secretBytes, recipe)

Stored in SodiumBuffer's fixed-length list format. Strings are stored as UTF8 byte arrays.

◆ toJson()

const std::string Password::toJson ( int  indent = -1,
const char  indent_char = ' ' 
) const

Serialize this object to a JSON-formatted string.

It can be reconstituted by calling the constructor with this string.

Parameters
indentThe number of characters to indent the JSON (optional)
indent_charThe character with which to indent the JSON (optional)
Returns
const std::string A Password serialized to JSON format.

◆ toSerializedBinaryForm()

const SodiumBuffer Password::toSerializedBinaryForm ( ) const

Serialize to byte array as a list of: (secretBytes, recipe)

Stored in SodiumBuffer's fixed-length list format. Strings are stored as UTF8 byte arrays.


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