CppSecurity 1.1.2.0
C++ Security Library
Loading...
Searching...
No Matches
password_generator.h
Go to the documentation of this file.
1
9#ifndef CPPSECURITY_PASSWORD_GENERATOR_H
10#define CPPSECURITY_PASSWORD_GENERATOR_H
11
12#include "password.h"
13
14#include "common/flags.h"
15
16namespace CppSecurity {
17
19enum class PasswordFlags
20{
21 none = 0x0,
22 lower = 0x1,
23 upper = 0x2,
24 digits = 0x4,
25 symbols = 0x8,
26};
27
29
34template <class TOutputStream>
35TOutputStream& operator<<(TOutputStream& stream, PasswordFlags flags);
36
37} // namespace CppSecurity
38
39// Register enum as flags to enable AND/OR/XOR logical operators with enum values!
41
42namespace CppSecurity {
43
45
52{
53public:
55
62 virtual ~PasswordGenerator() = default;
63
66
68 size_t length() const noexcept { return _length; }
70 PasswordFlags flags() const noexcept { return _flags; }
71
73
76 virtual std::password Generate() const;
77
79
83 virtual bool Validate(std::string_view password) const;
84
85private:
86 size_t _length;
87 PasswordFlags _flags;
88};
89
92} // namespace CppSecurity
93
95
96#endif // CPPSECURITY_PASSWORD_GENERATOR_H
virtual std::password Generate() const
Generate the strong password with the current password requirements.
size_t length() const noexcept
Get the password length.
PasswordGenerator & operator=(const PasswordGenerator &)=default
virtual ~PasswordGenerator()=default
PasswordGenerator(PasswordGenerator &&)=default
PasswordGenerator & operator=(PasswordGenerator &&)=default
virtual bool Validate(std::string_view password) const
Validate the given password with the current password requirements.
PasswordGenerator(const PasswordGenerator &)=default
PasswordFlags flags() const noexcept
Get the password flags.
Password string.
Definition password.h:53
TOutputStream & operator<<(TOutputStream &stream, CipherAlgorithm algorithm)
Definition cipher.inl:12
PasswordFlags
Password flags.
@ upper
Password must contain alphabet characters in upper case (A-Z)
@ none
Empty password flags.
@ symbols
Password must contain punctuation symbols (!"#$%&'()*+,-./:;<=>?@[]^_`{|}~)
@ lower
Password must contain alphabet characters in lower case (a-z)
@ digits
Password must contain digits (0-9)
Password string definition.
Password generator inline implementation.