
Password and PIN strength meter estimating guess-based strength with zxcvbn thresholds, PIN-pattern detection, optional memory‑mapped multilingual dictionaries, secure byte wiping, and thread‑safe dictionary management.
Kotlin Multiplatform password and PIN strength meter: a port of wultra/passphrase-meter, built on zxcvbn-c and Kotlin-JNI.
VERY_WEAK … STRONG), estimated by zxcvbn, with Wultra's strength thresholds.1357), repeating (692692),
possible dates (0304, 1990, 241065). This is a pure Kotlin port, verified against Wultra's 1.16M reference PINs.PassphraseTester.initialize() // loads the native library on JVM/Android, no-op on native
// Passwords
PassphraseTester.testPassword("correct horse") // PasswordStrength
// PINs
val result = PassphraseTester.testPin("1990") // PinTestResult(pinLength, issues)
if (PinTestIssue.POSSIBLY_DATE in result.issues) { /* "Is this your birthday?" */ }
// Non-digit PINs throw IllegalArgumentException; too short/long give TOO_SHORT / TOO_LONG.The dictionary is process-wide and shared by all callers. Loading a new one replaces the current one.
// From a URI. Works with Compose resources without a Compose dependency:
PassphraseTester.loadDictionaryFromUri(Res.getUri("files/en.dict"))
// From bytes (any source):
PassphraseTester.loadDictionary(bytes)
// Android: from assets, a content:// or file:// Uri
PassphraseTester.loadDictionaryFromAsset(context, "en.dict")
PassphraseTester.loadDictionary(context, uri)
PassphraseTester.hasDictionary()
PassphraseTester.freeDictionary()On Android, keep dictionaries uncompressed so they can be memory-mapped instead of read into memory:
androidResources { noCompress += "dict" }Don't modify a dictionary file in place while it is loaded. Replacing or deleting it is fine.
Prebuilt dictionaries are attached to each release, built
from zxcvbn-ts: ar, cs, da-dk, de, en, es-es, fa, fi, fr,
hr, id, it, ja, ko, ku, nl-be, pl, pt-br, ro, ru, th, tr, zh, plus common
(passwords only, also included in every language).
zxcvbn only matches ASCII, so words are stored as people type them in Latin letters: without accents (příliš →
prilis), romanized (사랑 → sarang, pinyin without tones) and, for Korean and Thai, as typed on that keyboard
with an English layout (사랑 → tkfkd, สวัสดี → l;ylfu).
When shipping dictionaries, include NOTICE-dictionaries.md (attached to each release) in your app's licenses: some
word lists require attribution.
Needs a C++ compiler, python3 and curl:
scripts/build-dictionaries.sh # all languages -> core/native/dictionaries/
scripts/build-dictionaries.sh en de # some (--list shows all)
scripts/build-dictionaries.sh --custom mylang words.txt [more.txt ...]Set DICT_OUT_DIR to write straight into your app's resources. Custom word lists have one word per line, most common
first; anything after a space is ignored, non-ASCII words are skipped, and several files are interleaved by rank.
The converted language lists in core/native/dictionaries-input/wordlists/ can be combined the same way, e.g.
--custom en-de .../en.txt .../de.txt.
git submodule update --init
scripts/build-zxcvbn.sh # libzxcvbn.a + patched header for every target -> core/native/zxcvbn/
scripts/build-dictionaries.sh # dictionaries + PIN reference results for the tests
./gradlew :core:jvmTest :core:linuxX64Test :core:macosArm64Test :core:iosSimulatorArm64TestThe scripts' output is git-ignored, so run them after cloning; a cinterop error about zxcvbn.h means
build-zxcvbn.sh hasn't run. On Linux, Apple targets are compiled with zig (or via nix).
NOTICE-dictionaries.md for the sources of the individual lists.Kotlin Multiplatform password and PIN strength meter: a port of wultra/passphrase-meter, built on zxcvbn-c and Kotlin-JNI.
VERY_WEAK … STRONG), estimated by zxcvbn, with Wultra's strength thresholds.1357), repeating (692692),
possible dates (0304, 1990, 241065). This is a pure Kotlin port, verified against Wultra's 1.16M reference PINs.PassphraseTester.initialize() // loads the native library on JVM/Android, no-op on native
// Passwords
PassphraseTester.testPassword("correct horse") // PasswordStrength
// PINs
val result = PassphraseTester.testPin("1990") // PinTestResult(pinLength, issues)
if (PinTestIssue.POSSIBLY_DATE in result.issues) { /* "Is this your birthday?" */ }
// Non-digit PINs throw IllegalArgumentException; too short/long give TOO_SHORT / TOO_LONG.The dictionary is process-wide and shared by all callers. Loading a new one replaces the current one.
// From a URI. Works with Compose resources without a Compose dependency:
PassphraseTester.loadDictionaryFromUri(Res.getUri("files/en.dict"))
// From bytes (any source):
PassphraseTester.loadDictionary(bytes)
// Android: from assets, a content:// or file:// Uri
PassphraseTester.loadDictionaryFromAsset(context, "en.dict")
PassphraseTester.loadDictionary(context, uri)
PassphraseTester.hasDictionary()
PassphraseTester.freeDictionary()On Android, keep dictionaries uncompressed so they can be memory-mapped instead of read into memory:
androidResources { noCompress += "dict" }Don't modify a dictionary file in place while it is loaded. Replacing or deleting it is fine.
Prebuilt dictionaries are attached to each release, built
from zxcvbn-ts: ar, cs, da-dk, de, en, es-es, fa, fi, fr,
hr, id, it, ja, ko, ku, nl-be, pl, pt-br, ro, ru, th, tr, zh, plus common
(passwords only, also included in every language).
zxcvbn only matches ASCII, so words are stored as people type them in Latin letters: without accents (příliš →
prilis), romanized (사랑 → sarang, pinyin without tones) and, for Korean and Thai, as typed on that keyboard
with an English layout (사랑 → tkfkd, สวัสดี → l;ylfu).
When shipping dictionaries, include NOTICE-dictionaries.md (attached to each release) in your app's licenses: some
word lists require attribution.
Needs a C++ compiler, python3 and curl:
scripts/build-dictionaries.sh # all languages -> core/native/dictionaries/
scripts/build-dictionaries.sh en de # some (--list shows all)
scripts/build-dictionaries.sh --custom mylang words.txt [more.txt ...]Set DICT_OUT_DIR to write straight into your app's resources. Custom word lists have one word per line, most common
first; anything after a space is ignored, non-ASCII words are skipped, and several files are interleaved by rank.
The converted language lists in core/native/dictionaries-input/wordlists/ can be combined the same way, e.g.
--custom en-de .../en.txt .../de.txt.
git submodule update --init
scripts/build-zxcvbn.sh # libzxcvbn.a + patched header for every target -> core/native/zxcvbn/
scripts/build-dictionaries.sh # dictionaries + PIN reference results for the tests
./gradlew :core:jvmTest :core:linuxX64Test :core:macosArm64Test :core:iosSimulatorArm64TestThe scripts' output is git-ignored, so run them after cloning; a cinterop error about zxcvbn.h means
build-zxcvbn.sh hasn't run. On Linux, Apple targets are compiled with zig (or via nix).
NOTICE-dictionaries.md for the sources of the individual lists.