Repository navigation
Releases
PwScore 3.1.0
Scoring changes
- Every-other sequences now count as sequences: the step-2 strings
02468,13579,acegikmoqsuwyandbdfhjlnprtvxz, and their reverses, join the existing digit and letter groups.Xk13579!now scores 5 (was 7), the same asXk12345!. - Each group still subtracts at most 1, and these windows count toward the "mostly sequences" rule.
- All 179 cases of the 3.0.0 snapshot keep their scores. The snapshot grows to 188 cases.
All 14 implementations and the web demo follow the new rule. The full rules are in spec/SPEC.md.
Installation
- Java (JitPack):
com.github.venshine:PwScore:3.1.0 - Go:
go get github.com/venshine/PwScore/go/v3@v3.1.0 - Swift, Dart, Python, Rust, C/C++ and Ruby: use tag
3.1.0, as shown in the README.
PwScore.jar below is the Java library.
PwScore 3.0.0
CheckPasswordStrength is now PwScore: the same scoring rules, with the same results, in 14 languages, plus an online demo that scores passwords locally in your browser.
Languages
Java, Kotlin (Multiplatform), Swift, Objective-C, Dart, JavaScript, Python, Go, Rust, C, C++, C#, Ruby and Perl. Every implementation is tested against the same snapshot of 179 expected scores (spec/score-snapshot.tsv). The rules are specified in spec/SPEC.md. See the README for how to install and call each one.
Scoring changes
The rules were reworked to close ways of making weak passwords look strong. Of the 118 cases in the 2.1.0 snapshot, 77 keep their score, 28 go up and 13 go down.
- Length is a continuous ladder from -2 (4 characters or fewer) to +5 (24 or more), measured as effective length: a run of one character counts as 2 and back-to-back repeated pieces count once (
Ab1!Ab1!Ab1!x: 12 → 3). - Character-class thresholds count distinct characters (
Pa1!followed by eleven!: 10 → 3). - Fullwidth ASCII is folded to ASCII; other non-ASCII characters form their own class instead of counting as symbols, and an emoji counts as one character.
- The dictionary grows from 13 to 84 words (English, pinyin, digit patterns), matches substitutions such as
p@ssw0rd, and subtracts 2. - Years and ddMMyyyy, MMddyyyy and yyMMdd dates are detected, as are keyboard columns, diagonals and the shifted symbol row; passwords mostly made of sequences lose one more point.
- A password made of few distinct characters loses a point; the "all one class" penalty now applies only below 6 characters.
- Fixed the all-same-character check, which treated spaces and other characters up to U+0020 as equal to the first one.
API (breaking)
| 2.x | 3.0.0 |
|---|---|
com.github.venshine:CheckPasswordStrength |
com.github.venshine:PwScore |
com.wx.pwd.CheckStrength.checkPasswordStrength(s) |
io.github.venshine.pwscore.PwScore.score(s) |
CheckStrength.getPasswordLevel(s) |
PwScore.level(s) |
CheckStrength.LEVEL |
PwScore.Level |
com.wx.pwd.StringUtils |
removed |
Installation
- Java:
implementation 'com.github.venshine:PwScore:3.0.0'from JitPack, or thePwScore.jarattached below - Go:
go get github.com/venshine/PwScore/go/v3@v3.0.0 - Swift / Objective-C: Swift Package Manager,
from: "3.0.0" - Other languages: see the README
CheckPasswordStrength 2.1.0
Scoring changes
Non-repeated passwords keep or lose points; nothing scores higher except the date case below. Short passwords are affected most: about 40% of random 4-8 character passwords score lower, while 9-16 character ones barely change (about 0.04%).
- Length gates apply to whole combination rules.
len > k && A || B || ...only gated the first pair, so uppercase scored higher than lowercase and 5-6 character passwords could reach MEDIUM.Ab1!xnow scores 3 (EASY) instead of 4. - Repeated patterns are scored as their unit. Only halves and thirds were checked before, so
Ab1!repeated 5 times scored 13 (EXTREMELY_STRONG).Ab1!Ab1!Ab1!now scores the same asAb1!, andPassw0rd!Passw0rd!drops from 11 to 7. A repeated unit that is already 16+ characters may gain 1 point, since the old "equal halves" penalty no longer applies. - Sequences inside the password are penalized. Runs of 4 or more consecutive letters, digits or keyboard keys anywhere in the password, in either direction and in any case, cost 1 point per kind. Only whole-string sequences were caught before.
Qwerty123!drops from 8 to 7. - Embedded dates are detected. An 8-digit
yyyyMMdddate anywhere in the password (years 1950-2049, real month lengths and leap years) costs 1 point.Tom19881010!drops from 7 to 6. The old rule only looked at all-digit passwords, which already scored 0, so it never changed an ASCII result.
API
- Only
null("password is null") and the empty string ("password is empty") throwIllegalArgumentException. Blank strings and the literal"null"used to throw and are now scored.
Other
- Character classes are counted in a single pass and repeat detection uses a KMP prefix function, so scoring is linear time: about 1.3-1.7x faster for a 16-character password, and under 100 ms for a 1,000,000-character input.
- New Swing sample app:
./gradlew :sample:run. - New score snapshot test (
test/score-snapshot.tsv) that pins every rule.
See CHANGELOG.md for details.
Installation
repositories {
maven { url = 'https://jitpack.io' }
}
implementation 'com.github.venshine:CheckPasswordStrength:2.1.0'Or download the attached jar (Java 8 bytecode).
CheckPasswordStrength 2.0.0
修复
- 连续字母、键盘序列、连续数字出现在密码开头时未扣分
- 字典检测写反,现在会识别包含字典词的密码(不区分大小写)
- 13 位及以上的纯数字密码抛出
NumberFormatException
不兼容变更
- 枚举
LEVEL.MIDIUM更名为LEVEL.MEDIUM - 部分密码评分变化,例如
Password123!由 8 分降为 7 分,详见 CHANGELOG.md
接入
repositories {
maven { url = 'https://jitpack.io' }
}
implementation 'com.github.venshine:CheckPasswordStrength:2.0.0'也可直接下载附件中的 jar(Java 8 字节码)。