Giter VIP home page Giter VIP logo

pwned-rs's Introduction

Crates.io Build Status MIT licensed Apache-2.0 licensed

pwned-rs

Check your passwords against Have I been pwned?

Usage

Add this to your Cargo.toml

[dependencies]
pwned = { git = "https://github.com/wisespace-io/pwned-rs.git" }

Check a password against the API and see the number of occurrences

It uses the range API, so only the first 5 characters of a SHA1 hashed password are sent to Have I been pwned?

use pwned::api::*;

#[tokio::main]
async fn main() {
    let pwned = PwnedBuilder::default()
        .build().unwrap();

    match pwned.check_password("password").await {
        Ok(pwd) => println!("Pwned? {} - Occurrences {}", pwd.found, pwd.count),
        Err(e) => println!("Error: {}", e),
    }
}

Check all breaches for an account

use pwned::api::*;
#[tokio::main]
async fn main() {
    
    let pwned = PwnedBuilder::default()
        .user_agent("my_user_agent")
        .api_key(std::env::var("HIBP_API_KEY").expect("You need to give your HIBP API key as the HIBP_API_KEY environment variable"))
        .build().unwrap();

    match pwned.check_email("[email protected]").await {
        Ok(answer) => {
            for breach in answer {
                println!("Service {:?}, breach date {:?} Domain: {:?}", breach.name, breach.breach_date, breach.domain);
            }
        },
        Err(e) => println!("Message: {}", e),
    }

}

pwned-rs's People

Contributors

alyoshavasilieva avatar jamesbirtles avatar michaelmelanson avatar paulgrandperrin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pwned-rs's Issues

Replace `error-chain` by `thiserror`

Because of this issue in error-chain rust-lang-deprecated/error-chain#240 , errors from this crate are impossible to propagate when the user is using failures or anyhow and maybe others.

More info can be found here:

Moreover error-chain is not maintained anymore and the fix has, and will never be merged: rust-lang-deprecated/error-chain#241

thiserror is the recommend crate to generate errors from libraries: https://nick.groenen.me/posts/rust-error-handling/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.