Skip to content

TheYkk/leaked-password

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Leaked password check

With this library you can check the password is probably leaked or not.

Pre generated bitset DB includes 6 Million leaked passwords stored in bloom filter bitset.

To generate your own bitset DB head into Db-generate and follow instructions.

Bloom filter

The current configuration is a 1 in 1 Million false positive rates. With bloom filter, you can make sure if data is not stored in the bitset. But bloom filter can generate false positives.

To change error rate, you need to generate your own bitset DB. After that you can change bitset DB like this

package main

import (
	"github.com/theykk/leaked-password"
	"os"
	"io"
)

func main() {
	myDB, _ := os.Open("my.db")
	defer myDB.Close()
	leakedpassword.CustomReader = myDB
}

Usage

package main

import (
	"github.com/theykk/leaked-password"
)

func registerUser(username, password string) error {
	// Check password is leaked
	isLeaked, err := leakedpassword.IsLeaked(password)
	if err != nil {
		return err
	}
		
	if isLeaked {
		// Password is leaked do something
	}
	return nil
}