-
Notifications
You must be signed in to change notification settings - Fork 43
/
Result.cs
98 lines (82 loc) · 3.54 KB
/
Result.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// TODO: These should probably be immutable
namespace Zxcvbn
{
/// <summary>
/// The results of zxcvbn's password analysis
/// </summary>
public class Result
{
/// <summary>
/// A calculated estimate of how many bits of entropy the password covers, rounded to three decimal places.
/// </summary>
public double Entropy { get; set; }
/// <summary>
/// The number of milliseconds that zxcvbn took to calculate results for this password
/// </summary>
public long CalcTime { get; set; }
/// <summary>
/// An estimation of the crack time for this password in seconds
/// </summary>
public double CrackTime { get; set; }
/// <summary>
/// A friendly string for the crack time (like "centuries", "instant", "7 minutes", "14 hours" etc.)
/// </summary>
public string CrackTimeDisplay { get; set; }
/// <summary>
/// A score from 0 to 4 (inclusive), with 0 being least secure and 4 being most secure calculated from crack time:
/// [0,1,2,3,4] if crack time is less than [10**2, 10**4, 10**6, 10**8, Infinity] seconds.
/// Useful for implementing a strength meter
/// </summary>
public int Score { get; set; }
/// <summary>
/// The sequence of matches that were used to create the entropy calculation
/// </summary>
public IList<Match> MatchSequence { get; set; }
/// <summary>
/// The password that was used to generate these results
/// </summary>
public string Password { get; set; }
}
/// <summary>
/// <para>A single match that one of the pattern matchers has made against the password being tested.</para>
///
/// <para>Some pattern matchers implement subclasses of match that can provide more information on their specific results.</para>
///
/// <para>Matches must all have the <see cref="Pattern"/>, <see cref="Token"/>, <see cref="Entropy"/>, <see cref="i"/> and
/// <see cref="j"/> fields (i.e. all but the <see cref="Cardinality"/> field, which is optional) set before being returned from the matcher
/// in which they are created.</para>
/// </summary>
public class Match
{
/// <summary>
/// The name of the pattern matcher used to generate this match
/// </summary>
public string Pattern { get; set; }
/// <summary>
/// The portion of the password that was matched
/// </summary>
public string Token { get; set; }
/// <summary>
/// The entropy that this portion of the password covers using the current pattern matching technique
/// </summary>
public double Entropy { get; set; }
// The following are more internal measures, but may be useful to consumers
/// <summary>
/// Some pattern matchers can associate the cardinality of the set of possible matches that the
/// entropy calculation is derived from. Not all matchers provide a value for cardinality.
/// </summary>
public int Cardinality { get; set; }
/// <summary>
/// The start index in the password string of the matched token.
/// </summary>
public int i { get; set; } // Start Index
/// <summary>
/// The end index in the password string of the matched token.
/// </summary>
public int j { get; set; } // End Index
}
}