Passphrase Meter for iOS Apps


This chapter describes how to get Wultra Passphrase Meter for iOS up and running in your app. In the current version, we support integration via Swift Package Manager and CocoaPods.

Swift Package Manager

Add repository as a package in Xcode UI and add WultraPassphraseMeter and WultraPassphraseMeterCore libraries as a dependency.

You can add WultraPassphraseMeter*LANGUAGENAME*Dictionary packages for better language support.

Alternatively, you can add the dependency manually. For example:

// swift-tools-version:5.4

import PackageDescription

let package = Package(
    name: "YourLibrary",
    platforms: [
    products: [
            name: "YourLibrary",
            targets: ["YourLibrary"]),
    dependencies: [
        .package(name: "WultraPassphraseMeter", url: "", .from("1.0.2")),
        .package(name: "WultraPassphraseMeterCore", url: "", .from("1.0.2")),
        .package(name: "WultraPassphraseMeterENDictionary", url: "", .from("1.0.2")),
    targets: [
            name: "YourLibrary",
            dependencies: ["WultraPassphraseMeter", "WultraPassphraseMeterCore", "WultraPassphraseMeterENDictionary"])


CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate PowerAuth library into your Xcode project using CocoaPods, specify it in your Podfile:

target '<Your Target App>' do
  pod 'WultraPassphraseMeter'

To achieve more accurate password testing results, you can add a dependency to additional dictionaries, designed for particular regions:

Additional pod Region or Language
pod 'WultraPassphraseMeter/Dictionary_en' For english speaking people
pod 'WultraPassphraseMeter/Dictionary_czsk' For people speaking in Czech or Slovak

Then, run the following command:

$ pod install


Note that we don’t develop applications for macOS, so we cannot provide support for this platform, but as you can see, the library’s “podspec” definition doesn’t limit its use for iOS only. So, you can use it also for your macOS projects. We’ll be happy to hear about your experience with such projects.


Before you start using the library, you need to add the following import into your swift source codes:

import WultraPassphraseMeter
// You need to import each additional dictionary manually
// when using Swift Package Manager. 
// This is not needed for CocoaPods integration.
// import WultraPassphraseMeterENDictionary

Password testing

In order to test the password strength, use the following code:

// If your app has an additional dependency on the english dictionary,  
// then you need to load that dictionary first.
// Test the password
let strength = PasswordTester.shared.testPassword("test")

You can evaluate any password. The result of such operation is a strength of the password with the following levels:

  • Very Weak
  • Weak
  • Moderate
  • Good
  • Strong

Password testing takes several things into account (keyboard patterns, alphabetical order, repetition, etc…). You can also add a dictionary of well-known words to get rid of passwords that looks strong to algorithms but are actually very common spoken words, or very frequent passwords.

Additional dictionaries

The password strength testing can be improved by loading an appropriate dictionary. Due to limitations in the underlying zxcvbn-c implementation, only one dictionary can be loaded in the memory at the same time. Fortunately, this technical limitation typically doesn’t cause problems in real-world scenarios, because people typically speak in one primary language. So, we decided to prefer fewer changes in the low-level “zxcvbn-c” implementation, over a more developer-friendly API.

We recommend you to use dictionaries in the following manners:

  1. Determine in which language your user speak
  2. Load an appropriate dictionary with using .loadDictionary() function
  3. Use the password testing functions
  4. Release previously loaded resources:

If you do not free the loaded dictionary, then the allocated resources will be released in the next .loadDictionary() call.

PIN testing

The PIN testing is slightly different to password testing, because the result of such test is a list of findings. Look for this example:

let passcode = "1456"
let result = PasswordTester.shared.testPin(passcode)
if result.isEmpty {
    // No issues were found. 
    // Note that this is typically very strict evaluation, so please read the rest
    // of this chapter. 

You can evaluate any PIN. The result of the testing is a collection of issues that were found in a PIN. These issues can be:

  • Not Unique - the passcode doesn’t have enough unique digits.
  • Repeating Digits - there is a significant amount of repeating digits in the passcode.
  • Has Pattern - repeating pattern was found in the passcode - 1357 for example.
  • Possibly Date - this passcode can be a date and possibly the birthday of the user.
  • Frequently Used - the passcode is in the list of most used passcodes.
  • Wrong Input - wrong input - the passcode must contain digits only.

Note that you should implement your additional logic, based on the sensitivity of the data you’re protecting with the passcode and on other security measures. Here’s an example what such evaluation may look like:

let passcode = "1456"
let result = PasswordTester.shared.testPin(passcode)
// We want different classifications for different pin length
// to not eliminate too many pins (to keep good pins around 95%)
if passcode.count <= 4 {
    if result.contains(.frequentlyUsed) || result.contains(.notUnique) {
        // warn the user
} else if passcode.count <= 6 {
    if result.contains(.frequentlyUsed) || result.contains(.notUnique) || result.contains(.repeatingCharacters) {
        // warn the user
} else {
    if result.contains(.frequentlyUsed) || result.contains(.notUnique) || result.contains(.repeatingCharacters) || result.contains(.patternFound) {
        // warn the user

Example project

The repository contains a simple example application, showing usage of the library:

  1. Open Source/examples/iOS/PassMeterExample folder
  2. Run pod install in the folder. This step is only required if the compilation fails at pod’s project self-check.
  3. Open PassMeterExample.xcworkspace Xcode workspace.
  4. Build and run an example application

If everything works fine, then you can test your passwords in the simulator (or on a real device):

iOS Example App


If you need any assistance, do not hesitate to drop us a line at [email protected] or our official channel.

Security Disclosure

If you believe you have identified a security vulnerability with Wultra Passphrase Meter, you should report it as soon as possible via email to [email protected]. Please do not post it to a public issue tracker.

Last updated on Feb 03, 2022 (10:30) Edit on Github Send Feedback


Mobile Security Suite

Passphrase Meter