Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vhosune/haveibeenpwned
Swift library for haveibeenpwned.com
https://github.com/vhosune/haveibeenpwned
ios swift
Last synced: about 1 month ago
JSON representation
Swift library for haveibeenpwned.com
- Host: GitHub
- URL: https://github.com/vhosune/haveibeenpwned
- Owner: vhosune
- License: mit
- Created: 2018-11-15T18:42:42.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-27T02:33:58.000Z (almost 5 years ago)
- Last Synced: 2024-10-12T11:58:54.261Z (about 1 month ago)
- Topics: ios, swift
- Language: Swift
- Size: 30.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HaveIBeenPwned
[![Language](https://img.shields.io/badge/language-swift-orange)](https://github.com/vhosune/HaveIBeenPwned)
[![Platform](https://img.shields.io/cocoapods/p/HaveIBeenPwned)](https://github.com/vhosune/HaveIBeenPwned)
[![HaveIBeenPwned](https://img.shields.io/badge/api-v3-blue)](https://haveibeenpwned.com/API/v3)
[![GitHub license](https://img.shields.io/github/license/vhosune/HaveIBeenPwned)](https://raw.githubusercontent.com/vhosune/HaveIBeenPwned/master/LICENSE)
[![GitHub release](https://img.shields.io/github/v/release/vhosune/HaveIBeenPwned?sort=semver)](https://github.com/vhosune/HaveIBeenPwned/releases)
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/HaveIBeenPwned)](https://cocoapods.org/pods/HaveIBeenPwned)
[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)Swift library for [haveibeenpwned.com](https://haveibeenpwned.com) using APIv3
**Notes:** Some API request needs a [paid API key](https://haveibeenpwned.com/API/Key)
## Requirements
- iOS 8.0+ / macOS 10.10+
- Swift 5+## Installation
### CocoaPods
[CocoaPods](https://cocoapods.org) is a dependency manager for Cocoa projects.
`Podfile`:
```ruby
pod 'HaveIBeenPwned'
```### Carthage
[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
`Cartfile`:
```ogdl
github "vhosune/HaveIBeenPwned"
```## Quick hands on
- Check if a password has already been pwned in a breach
```swift
import HaveIBeenPwned// init HaveIBeenPwned with its Settings
let pwned = HaveIBeenPwned(with: HaveIBeenPwned.Settings())// create a request
if let request = pwned.requestSearch(password: "password") {// fetch the request
let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
// parse the result
let result = pwned.parseResponse(data, response, error)
// handle the parsed result
if case .passwords(let ranges) = try? result.get() {
let count = HaveIBeenPwned.search(for: "password", in: ranges)
print("has been pwned \(count) times")
}
}
task.resume()
}
```- Check if a site has been breached
```swift
let request = pwned.requestBreach(name: "yahoo")
```- Check if a user account appears in a breach
```swift
// init HaveIBeenPwned with its Settings and the Api key
let pwned = HaveIBeenPwned(with: HaveIBeenPwned.Settings(apiKey: "YOUR_API_KEY"))
let request = pwned.requestBreached(account: "[email protected]")```