Git Product home page Git Product logo

haveibeenpwnedpkg's Introduction

GOLANG PACKAGE FOR THE HAVEIBEENPWN API

HOW THE API WORKS

first we need to hash your password in sha1 and get the 5 first characters of this hash. second, we need to send this 5 characters to the haveibeenpwn api at this address : https://api.pwnedpasswords.com/range/{{your_five_characters_here}} and the server will return us a list of all hashed passwords starting with these 5 same characters and how many times they have been pwn.

example :

password =SHA1=> 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8

first five characters = 5baa6

we send this : https://api.pwnedpasswords.com/range/5baa6

example image

now, we need to find your string without the five first characters in the list of hashed passwords.

on your browser : ctrl + f and search this string 1e4c9b93f3f0682250b6cf8331b7ee68fd8 (the end of the password hash)

example image

here you can see the password password has been pwn 3861493 times.

this API is very clever because your password or its hash is never sent in clear.

INSTALLATION

go get github.com/TRIKKSS/haveibeenpwnedpkg

USAGE OF MY PACKAGE

import "github.com/TRIKKSS/haveibeenpwnedpkg"

haveibeenpwnedpkg.HaveibeenpwnPassword("password") // return how many times the password has been pwn and errors

EXAMPLE

package main 

import(
    "github.com/TRIKKSS/haveibeenpwnedpkg"
    "fmt"
    "os"
)
func main() {
    if len(os.Args) != 2 {
        fmt.Printf("usage : %s password\n", os.Args[0])
        os.Exit(1)
    }
    how, err := haveibeenpwnedpkg.HaveibeenpwnPassword(os.Args[1]/*your password*/)

    if err != nil {
        /* check errors */
        panic(err)
    }
    if how > 0{
        fmt.Println("your password has been pwn", how, "times.")
    } else {
        fmt.Println("password safe.")
    }
}

test of the above script :

example image

haveibeenpwnedpkg's People

Contributors

trikkss avatar

Watchers

 avatar

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.