Add UTF-8 tests

This commit is contained in:
Zahary Karadjov 2020-10-16 14:50:32 +03:00
parent 359b774183
commit ea6de3427d
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
1 changed files with 19 additions and 0 deletions

View File

@ -1,6 +1,11 @@
import
../zxcvbn
proc passwordEntropy(x: string): float =
result = zxcvbn.passwordEntropy(x)
echo x, " = ", result
# ASCII passwords:
let
a = passwordEntropy "a"
cat = passwordEntropy "cat"
@ -21,4 +26,18 @@ doAssert remixedQwerty > cat
doAssert remixedQwerty > a
doAssert remixedQwerty > longRepeatingSequence
# UTF-8 Passwords:
let
bulgarianPassword = passwordEntropy("парола")
bulgarianRepeatingSeq = passwordEntropy("яяяяяя")
japanesePassword = passwordEntropy("パスワード")
japaneseRepeatingSeq = passwordEntropy("パパパパパ")
chinesePassword = passwordEntropy("密碼")
chineseFourWords = passwordEntropy("正確的馬電池釘書釘")
doAssert bulgarianPassword > bulgarianRepeatingSeq
doAssert japanesePassword > japaneseRepeatingSeq
doAssert chineseFourWords > chinesePassword
echo "SUCCESS"