Skip to content
Snippets Groups Projects
Select Git revision
  • 4838dfdd91f142f06aa5d2d2402505fd61df672d
  • main default protected
  • development
  • integration
  • v1.1.5
  • v1.1.4
  • v1.1.3
  • v1.1.2
  • v1.1.1
  • v1.1.0
  • v1.0.0
11 results

PasswordGenerator.swift

Blame
  • Dariusz Rybicki's avatar
    Dariusz Rybicki authored
    fbc51204
    History
    PasswordGenerator.swift 551 B
    import Bindings
    
    public struct PasswordGenerator {
      public var run: (Int) -> Data
    
      public func callAsFunction(numBytes: Int = 32) -> Data {
        run(numBytes)
      }
    }
    
    extension PasswordGenerator {
      public static let live = PasswordGenerator { numBytes in
        guard let secret = BindingsGenerateSecret(numBytes) else {
          fatalError("BindingsGenerateSecret returned `nil`")
        }
        return secret
      }
    }
    
    #if DEBUG
    extension PasswordGenerator {
      public static let failing = PasswordGenerator { _ in
        fatalError("Not implemented")
      }
    }
    #endif