password

package module
v0.0.0-...-2486e62 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2020 License: MIT Imports: 6 Imported by: 0

README

password

to generate password automatically

test
package main

import (
	"github.com/ailose/password"
	"log"
)


func main() {
	//get new password
	pwd := password.GenID()
	pwdInfo := password.GetNewPassword(pwd)
	// check password
	result, err := password.CheckPassword(pwdInfo.Pwd, pwdInfo.PasswordHash, pwdInfo.Salt)
	if err != nil {
		log.Fatal("check password err:", err)
	}
	if result == false {
		log.Fatal("the passowrd is wrong!")
	}
}

Documentation

Index

Constants

View Source
const MinPasswordCost = 10

Variables

This section is empty.

Functions

func CheckPassword

func CheckPassword(password, passwordHash, salt string) (bool, error)

func GenID

func GenID() string

Types

type PWD

type PWD struct {
	Salt         string
	PasswordHash string
	Pwd          string
}

func GetNewPassword

func GetNewPassword(pwd string) (*PWD, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL