mirror of
https://github.com/wneessen/apg-go.git
synced 2024-09-12 00:12:47 +02:00
This commit introduces the .gitignore configuration file and adds SPDX headers to several files including test and documentation files. The headers provide license information in a standardized format which can be easily picked up by automated tools for license compliance checks. Additionally, it deleted a .idea/.gitignore file, which is a project specific IDE configuration file not necessary for the repository. It also introduced a README.md file providing more insightful information about the project.
20 lines
555 B
Go
20 lines
555 B
Go
// SPDX-FileCopyrightText: 2021-2024 Winni Neessen <wn@neessen.dev>
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package apg
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/wneessen/go-hibp"
|
|
)
|
|
|
|
// HasBeenPwned checks the given password string against the HIBP pwned
|
|
// passwords database and returns true if the password has been leaked
|
|
func HasBeenPwned(password string) (bool, error) {
|
|
hc := hibp.New(hibp.WithHTTPTimeout(time.Second*2),
|
|
hibp.WithPwnedPadding())
|
|
matches, _, err := hc.PwnedPassAPI.CheckPassword(password)
|
|
return matches != nil && matches.Count != 0, err
|
|
}
|