StormByte C++ Library: Crypto module 0.0.9999
StormByte-Crypto is a StormByte library module for handling cryptographic operations
Loading...
Searching...
No Matches
password.hxx
1#pragma once
2
3#include <StormByte/crypto/visibility.h>
4
5#include <cstddef>
6#include <memory>
7#include <string>
8#include <utility>
9
10namespace StormByte::Crypto::Helpers {
11 struct SecureContent;
12 struct PasswordAccess;
13}
14
19namespace StormByte::Crypto {
20
36 class STORMBYTE_CRYPTO_PUBLIC Password {
37 public:
42 explicit Password(std::string value) noexcept;
43
48 explicit Password(const char* value) noexcept;
49
55 Password(const void* data, std::size_t size) noexcept;
56
61 Password(const Password& other) = default;
62
67 Password(Password&& other) noexcept = default;
68
73 ~Password() = default;
74
80 Password& operator=(const Password& other) = default;
81
87 Password& operator=(Password&& other) noexcept = default;
88
93 std::size_t Size() const noexcept;
94
99 bool Empty() const noexcept;
100
105 explicit operator bool() const noexcept;
106
112 bool operator==(const Password& other) const noexcept;
113
119 bool operator!=(const Password& other) const noexcept;
120
121 private:
122 friend struct Helpers::PasswordAccess;
123
124 std::shared_ptr<Helpers::SecureContent> m_data;
125 };
126}
Secure, reference-counted container for passwords and binary key material.
Definition password.hxx:36
Password & operator=(Password &&other) noexcept=default
Move assignment operator.
Password(Password &&other) noexcept=default
Move constructor.
Password(const void *data, std::size_t size) noexcept
Construct from raw bytes (exact size, no null terminator added).
Password(const Password &other)=default
Copy constructor.
std::size_t Size() const noexcept
Length of the stored material in bytes.
Password & operator=(const Password &other)=default
Copy assignment operator.
~Password()=default
Destructor. Wipes the underlying buffer when this is the last owner.
Password(std::string value) noexcept
Construct from a std::string (copied byte-for-byte, then wiped).
Password(const char *value) noexcept
Construct from a C string (copied byte-for-byte up to the terminator).