22 lines
402 B
Go
22 lines
402 B
Go
package utils
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"log"
|
|
|
|
"golang.org/x/crypto/bcrypt"
|
|
)
|
|
|
|
func HashPassword(password string) ([]byte, error) {
|
|
return bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
|
|
}
|
|
|
|
func PrettyPrintJson(data interface{}) {
|
|
b, err := json.MarshalIndent(data, "", " ")
|
|
if err != nil {
|
|
fmt.Println("error:", err)
|
|
}
|
|
log.Println(string(b))
|
|
}
|