Skip to content
Snippets Groups Projects
Commit caa34e37 authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

Add numBytes parameter to PasswordGenerator

parent 79e8e4ac
No related branches found
No related tags found
1 merge request!2Bindings API wrapper
import Bindings import Bindings
public struct PasswordGenerator { public struct PasswordGenerator {
public var run: () -> Data public var run: (Int) -> Data
public func callAsFunction() -> Data { public func callAsFunction(numBytes: Int = 32) -> Data {
run() run(numBytes)
} }
} }
extension PasswordGenerator { extension PasswordGenerator {
public static let live = PasswordGenerator { public static let live = PasswordGenerator { numBytes in
guard let secret = BindingsGenerateSecret(32) else { guard let secret = BindingsGenerateSecret(numBytes) else {
fatalError("BindingsGenerateSecret returned `nil`") fatalError("BindingsGenerateSecret returned `nil`")
} }
return secret return secret
...@@ -19,7 +19,7 @@ extension PasswordGenerator { ...@@ -19,7 +19,7 @@ extension PasswordGenerator {
#if DEBUG #if DEBUG
extension PasswordGenerator { extension PasswordGenerator {
public static let failing = PasswordGenerator { public static let failing = PasswordGenerator { _ in
Data() Data()
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment