You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
349 B

package service
import (
"fmt"
"golang.org/x/crypto/bcrypt"
)
// bcrypt加密
func encode() {
password, err := bcrypt.GenerateFromPassword([]byte("123"), 10)
if err != nil {
panic(err)
}
fmt.Println(string(password))
err = bcrypt.CompareHashAndPassword(password, []byte("123"))
if err != nil {
panic(err)
}
fmt.Println("correct")
}