Password

public struct Password

Password generator

  • Length of the password

    Declaration

    Swift

    public var length: Int
  • Number of passwords to generate

    Declaration

    Swift

    public var count: Int
  • Password flags and criteria

    Declaration

    Swift

    public var flags: PasswordFlags
  • This method is mimicked from Sources/Cpwgen/lib/pwgen.c & essentially replaces the main function.

    Declaration

    Swift

    func generatePassword(_ length: Int, flags: PasswordFlags) throws -> String

    Parameters

    length

    Length of password

    flags

    Password flags

    Return Value

    A random password

Password

  • Default password length 8

    Declaration

    Swift

    static var defaultLength: Int { get }
  • Default number of passwords 1

    Declaration

    Swift

    static var defaultCount: Int { get }
  • Default flags contain digits and uppercase

    Declaration

    Swift

    static var defaultFlags: PasswordFlags { get }
  • Generates the passwords

    Declaration

    Swift

    func generate() throws -> [String]

    Return Value

    List of passwords

  • Generates the passwords with given length and flags

    Declaration

    Swift

    static func generate(
        length: Int = defaultLength,
        count: Int = defaultCount,
        flags: PasswordFlags = defaultFlags
    ) -> [String]

    Parameters

    length

    Length of the password

    count

    Number of passwords to generate

    flags

    Password flags and criteria

    Return Value

    List of passwords. Returns empty in case of error