A cryptographically secure string.
More...
#include <crypto.h>
|
| | string (const size_t &l=0) |
| | Construct a string with a fixed, zeroed size.
|
| |
| | string (const std::string &string) |
| | Construct a string from a std::string.
|
| |
| | string (const unsigned char *string, const size_t &l) |
| | Construct a string from a character array and size.
|
| |
| | string (const char *string) |
| | Construct a string from a character array.
|
| |
| | ~string () |
| | Destroy the string.
|
| |
| string | substr (const size_t &start, const size_t &count=std::string::npos) const |
| | Return a subset of the string.
|
| |
| void | resize (const size_t &n, const unsigned char &v=0) |
| | Resize the string.
|
| |
| void | append (const string &s) |
| | Append another string to end of the caller.
|
| |
| std::string | str () |
| | Return a hexadecimal representation of the crypto::string.
|
| |
| const size_t | length () const |
| | Return the length of the string.
|
| |
| unsigned char * | bytes () |
| | Return a mutable byte array that can be directly manipulated.
|
| |
| const unsigned char * | bytes () const |
| | Return a immutable byte array of the internal values.
|
| |
| std::string | to () const |
| | Return a std::string representation of the string.
|
| |
| unsigned char & | operator[] (const size_t &pos) |
| | Index the string.
|
| |
| const bool | operator== (const string &cmp) const |
| | Equivalence operator.
|
| |
| string | operator+ (const string &a) const |
| | Concatonation operator.
|
| |
A cryptographically secure string.
◆ string() [1/4]
| crypto::string::string |
( |
const size_t & | l = 0 | ) |
|
|
inline |
Construct a string with a fixed, zeroed size.
- Parameters
-
| l | The size of the object (It can still grow/shrink, but this allows us to pass it into memcpy where it expects a certain size). |
◆ string() [2/4]
| crypto::string::string |
( |
const std::string & | string | ) |
|
|
inline |
Construct a string from a std::string.
- Parameters
-
◆ string() [3/4]
| crypto::string::string |
( |
const unsigned char * | string, |
|
|
const size_t & | l ) |
|
inline |
Construct a string from a character array and size.
- Parameters
-
| string | The input string. |
| l | The size of the string. |
- Warning
- This function does not check if the provided size is bounded by the size of the string!
◆ string() [4/4]
| crypto::string::string |
( |
const char * | string | ) |
|
|
inline |
Construct a string from a character array.
- Parameters
-
- Warning
- This function uses strlen to determine length. If your string is not null terminated, this function will read out of bounds!
◆ ~string()
| crypto::string::~string |
( |
| ) |
|
|
inline |
◆ append()
| void crypto::string::append |
( |
const string & | s | ) |
|
|
inline |
Append another string to end of the caller.
- Parameters
-
◆ bytes() [1/2]
| unsigned char * crypto::string::bytes |
( |
| ) |
|
|
inline |
Return a mutable byte array that can be directly manipulated.
- Returns
- The beginning of the string.
◆ bytes() [2/2]
| const unsigned char * crypto::string::bytes |
( |
| ) |
const |
|
inline |
Return a immutable byte array of the internal values.
- Returns
- The byte array.
◆ length()
| const size_t crypto::string::length |
( |
| ) |
const |
|
inline |
Return the length of the string.
- Returns
- The length.
◆ operator+()
Concatonation operator.
- Parameters
-
- Returns
- The caller concatenated with the input.
◆ operator==()
| const bool crypto::string::operator== |
( |
const string & | cmp | ) |
const |
|
inline |
Equivalence operator.
- Parameters
-
| cmp | The string to compare against. |
- Returns
- Whether the strings are equal.
◆ operator[]()
| unsigned char & crypto::string::operator[] |
( |
const size_t & | pos | ) |
|
|
inline |
Index the string.
- Parameters
-
- Returns
- The mutable byte at that position.
- Exceptions
-
| std::out_of_range | if the position is out of bounds. |
◆ resize()
| void crypto::string::resize |
( |
const size_t & | n, |
|
|
const unsigned char & | v = 0 ) |
|
inline |
Resize the string.
- Parameters
-
| n | The new size. |
| v | The character to use to fill new spaces |
◆ str()
| std::string crypto::string::str |
( |
| ) |
|
|
inline |
Return a hexadecimal representation of the crypto::string.
- Returns
- The hex string.
◆ substr()
| string crypto::string::substr |
( |
const size_t & | start, |
|
|
const size_t & | count = std::string::npos ) const |
|
inline |
Return a subset of the string.
- Parameters
-
| start | The left bound |
| count | The amount of characters to read from the left bound. std::string::npos means everything until the end of the string. |
- Returns
- The substring.
◆ to()
| std::string crypto::string::to |
( |
| ) |
const |
|
inline |
Return a std::string representation of the string.
- Returns
- The string.
The documentation for this class was generated from the following file: