31 lines
607 B
Go
31 lines
607 B
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"os"
|
|
|
|
"golang.org/x/crypto/bcrypt"
|
|
)
|
|
|
|
func HashPassword(password string) (string, error) {
|
|
bytes, err := bcrypt.GenerateFromPassword([]byte(password), 14)
|
|
return string(bytes), err
|
|
}
|
|
|
|
func main() {
|
|
scanner := bufio.NewScanner(os.Stdin)
|
|
fmt.Print("Enter a password : ")
|
|
scanner.Scan()
|
|
primary := scanner.Text()
|
|
fmt.Print("Enter a password : ")
|
|
scanner.Scan()
|
|
second := scanner.Text()
|
|
|
|
if primary != second {
|
|
fmt.Println("password do not match")
|
|
return
|
|
}
|
|
hash, _ := HashPassword(primary)
|
|
fmt.Println("La version hasher du password :", string(hash))
|
|
}
|