PwnedPasswords implements a client for HaveIBeenPwned.com's Pwned Passwords API v2 in Swift.
- Its only dependencies are
Foundation
andCommonCrypto
. - Does not disclose the password being checked to third parties. Only the first 5 characters of the password sha1 hash are disclosed (See k-Anonymity.)
- Can target iOS, macOS, tvOS, and watchOS.
PwnedPasswords.shared.check(password: "password1") { (result) in
switch result {
case .success( let count ):
if count > 0 {
print( "This password has been found \(count) times in compromised accounts" )
} else {
print( "This password wasn't found to be compromised." )
}
case .failure:
print( "This password could not be checked at this time" )
}
}
PwnedPasswords is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'SwiftPwnedPasswords'
Copy PwnedPasswords.swift
to your project.
PwnedPasswords is available under the MIT license. See the LICENSE file for more info.