/
DBZxcvbn.m
49 lines (37 loc) · 1.05 KB
/
DBZxcvbn.m
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
//
// DBZxcvbn.m
// Zxcvbn
//
// Created by Leah Culver on 2/9/14.
// Copyright (c) 2014 Dropbox. All rights reserved.
//
#import "DBZxcvbn.h"
#import <QuartzCore/QuartzCore.h>
@interface DBZxcvbn ()
@property (nonatomic, strong) DBMatcher *matcher;
@property (nonatomic, strong) DBScorer *scorer;
@end
@implementation DBZxcvbn
- (id)init
{
self = [super init];
if (self != nil) {
self.matcher = [[DBMatcher alloc] init];
self.scorer = [[DBScorer alloc] init];
}
return self;
}
- (DBResult *)passwordStrength:(NSString *)password
{
return [self passwordStrength:password userInputs:nil];
}
- (DBResult *)passwordStrength:(NSString *)password userInputs:(NSArray *)userInputs
{
CFTimeInterval start = CACurrentMediaTime();
NSArray *matches = [self.matcher omnimatch:password userInputs:userInputs];
DBResult *result = [self.scorer minimumEntropyMatchSequence:password matches:matches];
CFTimeInterval end = CACurrentMediaTime();
result.calcTime = (end - start) * 1000.0;
return result;
}
@end