PwnedPasswords 0.1.4

PwnedPasswords 0.1.4

Christoffer Buusmann 维护。



PwnedPasswords

CI Status Version License Platform

要求

Swift 4.0

重要

这个库永远不会通过网络发送密码也不会存储处理过的密码。您可以在这里阅读关于它是如何工作的

安装

PwnedPasswords 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中

pod 'PwnedPasswords'

PwnedPasswords.swiftApiClient.swift 复制到您的项目。

使用方法

class ViewController: UIViewController {

  @IBOutlet weak var textField: UITextField!

  @IBAction func buttonDidPress(_ sender: Any) {
    guard let text = textField.text else { return }
    let client = PwnedPasswords()

    client.check(text) { occurences, error in
      guard error == nil else {
        print(error)
        return
      }
      
      if let occurences = occurences {
        if occurences > 0 {
          print("🛑 The password you entered has been in a breach")
        } else {
          print("✅ The password you entered was not found")
        }
      }
    }
  }
}

免责声明

这是一个基于 haveibeenpwned.com/Passwords 的包装器,由 Troy Hunt 创建。Troy 创建了这项服务并亲自提供。请负责任地使用,感谢 Troy 制造了如此惊人的事物🎉

SHA1 算法来自 https://github.com/idrougge/sha1-swift

作者

foffer, [email protected]

许可证

PwnedPasswords 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。