Swiftpack.co -  scr037/zxcvbn-swift as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
scr037/zxcvbn-swift
This is a contribution to the low budget password strength checker (https://github.com/dropbox/zxcvbn) compatible with swift package manager.
.package(url: "https://github.com/scr037/zxcvbn-swift.git", from: "1.2.0")

zxcvbn-swift

This is a swift compatible implementation of the password strength checker zxcvbn and a relies on the one specific contribution aimed for iOS. Check it out here. zxcvbn-swift is easier to integrate since it's compabile with Swift Package Manager.

Installation

Using swift package manager. Follow instructions here.

https://github.com/scr037/zxcvbn-swift

Usage

One to use zxcvbn-swift is to use DBPasswordStrengthMeter. This is a built-in component from the original implementation:

import ZxcvbnSwift

lazy var meterView = DBPasswordStrengthMeterView()

lazy var passwordField: UITextField = {
    let field = UITextField()
    field.isSecureTextEntry = true
    field.autocorrectionType = .no
    field.autocapitalizationType = .none
    field.placeholder = "Type a password here"
    field.addTarget(self, action: #selector(textFieldEditingDidChange(_:)), for: .editingChanged)
    field.rightViewMode = .always
    field.rightView = self.meterView
    field.borderStyle = .roundedRect
    return field
}()

// You can add a target to your editing text field or implement
// your preferred method from UITextFieldDelegate.
@objc func textFieldEditingDidChange(_ textField: UITextField) {
    guard let password = textField.text else { return }
    self.meterView.scorePassword(password)
}

If you prefer creating a custom UI component for diplaying your password strength, you can use DBZxcvbn straight away:

import ZxcvbnSwift

lazy var let checker = DBZxcvbn()

{ ... }

// You can add a target to your editing text field or implement
// your preferred method from UITextFieldDelegate.
@objc func textFieldEditingDidChange(_ textField: UITextField) {
    guard let password = textField.text else { return }
    self.meterView.scorePassword(password)
    let strength = checker.passwordStrength(password)
    // Score is an Int32 representation between 0 and 4. 
    // You can easily display this result within a UIProgressView 
    // by multiplying for a 0.25 factor.
    notifyPasswordStrength(strength?.score)
}

GitHub

link
Stars: 0
Last commit: 4 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

Set minimum deployment target to iOS 13
4 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API