Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created September 13, 2019 23:11
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/44f3d5d2b8350e57b87c24254e1a3830 to your computer and use it in GitHub Desktop.
Save parzibyte/44f3d5d2b8350e57b87c24254e1a3830 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"golang.org/x/crypto/bcrypt"
)
func main() {
contraseñaPlana := "123"
contraseñaPlanaComoByte := []byte(contraseñaPlana)
hash, err := bcrypt.GenerateFromPassword(contraseñaPlanaComoByte, bcrypt.DefaultCost) //DefaultCost es 10
if err != nil {
fmt.Println(err)
}
hashComoCadena := string(hash)
fmt.Printf("El hash generado a partir de %s es %s\n", contraseñaPlana, hashComoCadena)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment