PRCYCoin
2.0.0.7rc1
P2P Digital Currency
src
zxcvbn
zxcvbn.cpp
Go to the documentation of this file.
1
#include <
zxcvbn/zxcvbn.h
>
2
3
#include <
zxcvbn/util.hpp
>
4
#include <
zxcvbn/scoring.hpp
>
5
#include <
zxcvbn/matching.hpp
>
6
7
extern
"C"
{
8
9
struct
zxcvbn_match_sequence
{
10
std::vector<zxcvbn::Match>
sequence
;
11
};
12
13
int
zxcvbn_password_strength
(
const
char
*password,
const
char
*
const
*user_inputs,
14
zxcvbn_guesses_t
*guesses,
15
zxcvbn_match_sequence_t
*pmseq) {
16
try
{
17
std::vector<std::string> sanitized_inputs;
18
if
(user_inputs) {
19
while
(*user_inputs) {
20
sanitized_inputs.push_back(
zxcvbn::util::ascii_lower
(*user_inputs));
21
user_inputs++;
22
}
23
}
24
25
auto
matches =
zxcvbn::omnimatch
(password, sanitized_inputs);
26
auto
result =
zxcvbn::most_guessable_match_sequence
(password, matches,
false
);
27
28
if
(guesses) {
29
*guesses = result.guesses;
30
}
31
32
if
(pmseq) {
33
std::vector<zxcvbn::Match> sequence;
34
std::move(result.sequence.begin(), result.sequence.end(),
35
std::back_inserter(sequence));
36
*pmseq =
new
zxcvbn_match_sequence
{std::move(sequence)};
37
}
38
39
return
0;
40
}
41
catch
(...) {
42
return
-1;
43
}
44
}
45
46
void
zxcvbn_match_sequence_destroy
(
zxcvbn_match_sequence_t
mseq) {
47
delete
mseq;
48
}
49
50
}
zxcvbn::most_guessable_match_sequence
ScoringResult most_guessable_match_sequence(const std::string &password, std::vector< Match > &matches, bool exclude_additive)
Definition:
scoring.cpp:93
zxcvbn_password_strength
int zxcvbn_password_strength(const char *password, const char *const *user_inputs, zxcvbn_guesses_t *guesses, zxcvbn_match_sequence_t *pmseq)
Definition:
zxcvbn.cpp:13
zxcvbn::util::ascii_lower
std::string ascii_lower(const std::string &in)
Definition:
util.cpp:15
zxcvbn.h
zxcvbn::omnimatch
std::vector< Match > omnimatch(const std::string &password, const std::vector< std::string > &ordered_list)
Definition:
matching.cpp:109
zxcvbn_match_sequence
Definition:
zxcvbn.cpp:9
scoring.hpp
zxcvbn_match_sequence_destroy
void zxcvbn_match_sequence_destroy(zxcvbn_match_sequence_t mseq)
Definition:
zxcvbn.cpp:46
zxcvbn_match_sequence::sequence
std::vector< zxcvbn::Match > sequence
Definition:
zxcvbn.cpp:10
zxcvbn_guesses_t
double zxcvbn_guesses_t
Definition:
zxcvbn.h:10
matching.hpp
util.hpp
Generated on Tue Apr 28 2026 00:03:06 for PRCYCoin by
1.8.17