2 * Copyright (C) 2015 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18import Ubuntu.Components 1.2
21 property string password: ""
22 readonly property int passwordScore: scorePassword(password)
24 function scorePassword(pass) {
29 // award every unique letter until 5 repetitions
30 var letters = Object();
31 for (var i=0; i<pass.length; i++) {
32 letters[pass[i]] = (letters[pass[i]] || 0) + 1;
33 score += 5.0 / letters[pass[i]];
36 // bonus points for mixing it up
38 digits: /\d/.test(pass),
39 lower: /[a-z]/.test(pass),
40 upper: /[A-Z]/.test(pass),
41 nonWords: /\W/.test(pass),
44 var variationCount = 0;
45 for (var check in variations) {
46 variationCount += (variations[check] === true) ? 1 : 0;
48 score += (variationCount - 1) * 10;
50 return parseInt(score);
54 id: passwordStrengthMeter
62 if (passwordScore > 80)
64 else if (passwordScore > 60)
66 else if (passwordScore >= 30)
71 visible: password.length > 0
75 id: passwordStrengthInfo
79 top: passwordStrengthMeter.bottom
83 if (password.length < 8)
84 return i18n.tr("Password too short")
85 else if (passwordScore > 80)
86 return i18n.tr("Strong password");
87 else if (passwordScore > 60)
88 return i18n.tr("Fair password")
89 if (passwordScore >= 30)
90 return i18n.tr("Weak password");
92 return i18n.tr("Very weak password");
96 font.weight: Font.Light
97 visible: password.length > 0
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list