Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created September 13, 2019 23:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/ed48acbd79856b0c6d7a341326e81f5d to your computer and use it in GitHub Desktop.
Save parzibyte/ed48acbd79856b0c6d7a341326e81f5d to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"golang.org/x/crypto/bcrypt"
)
func main() {
hash := "$2a$10$yXR.Jd79OMcHfNK8zZU5N.nQ7ZL5N1d65sGIbPr.vIf6Q3o7e540i"
hashComoByte := []byte(hash)
contraseña := "123"
contraseñaComoByte := []byte(contraseña)
error := bcrypt.CompareHashAndPassword(hashComoByte, contraseñaComoByte)
if error == nil {
fmt.Println("Las contraseñas coinciden :)")
} else {
fmt.Println("Las contraseñas no coinciden. El error es: ", error)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment