PwnedPasswords
PwnedPasswords 实现了 Swift 中 HaveIBeenPwned.com 的 Pwned Passwords API v2 客户端。
- 它的唯一依赖项是
Foundation
和CommonCrypto
。 - 不会向第三方披露被检查的密码。只公开密码的 sha1 哈希值 的前 5 个字符(参见 k-Anonymity。)
- 可以针对 iOS、macOS、tvOS 和 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" )
}
}
安装:CocoaPods
PwnedPasswords 可以通过 CocoaPods 获取。要安装,只需将以下行添加到您的 Podfile
pod 'PwnedPasswords'
安装:手动
将 PwnedPasswords.swift
复制到您的项目中。
协议
PwnedPasswords 项基于 MIT 协议。更多详情请参阅 LICENSE 文件。