Swiftpack.co - moriturus/Ainu as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by moriturus.
moriturus/Ainu 6.0.0
Password Validator & Strength Evaluator influenced by Navajo and written in Swift completely.
⭐️ 10
🕓 4 years ago
iOS macOS
.package(url: "https://github.com/moriturus/Ainu.git", from: "6.0.0")

Ainu

Carthage compatible MIT License

Password Validator & Strength Evaluator influenced by Navajo.
Ainu is completely written in Swift 4.

Ainu is named in honour of the famed non-Japonic Languages speakers in the north of Japan.

Requirement

  • OSX 10.10+
  • iOS 9.0+
  • watchOS 3.0+
  • tvOS 9.0+

Installation

If you want to use Carthage, please use the commitment tagged 5.0.1

Swift Package Manager

Add this lines to your Package.swift.

dependencies: [
    .package(
        url: "https://github.com/moriturus/Ainu.git",
        from: "6.0.0"
    )
]

Usage

Validating Password

let password = "abc123"

// default validator's rule is `LengthRule(minimum: 8, maximum: 128)`
let validator = Validator()

let result = validator.validate(password)

switch result {

case .OK:
    // do something with the validated password
    break

case .Failure(let failingRules):
    failingRules.forEach { rule in
        NSLog(rule.localizedErrorDescription)
    }

}

Available Validation Rules

  • Allowed Characters
  • Required Characters (e.g. lowercase, uppercase, decimal, symbol)
  • Non-Dictionary Word (OSX/iOS only)
  • Minimum / Maximum Length
  • Predicate Match
  • Regular Expression Match
  • Function Evaluation

Evaluating Password Strength

Password strength is evaluated in terms of information entropy.

let password = "password"
let strength = Strength(password: password)

NSLog(strength.description) // prints "Very Weak"

Contact

Henrique Sasaki Yuya

License

Ainu is available under the MIT license. See the LICENSE file for more info.

GitHub

link
Stars: 10
Last commit: 4 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

2.0.3
7 years ago
  • Add a rule uses Strength.

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