Chuỗi bài: Go
go
28 dòng
· Cập nhật 2026-04-18
main.go
Go/Baasid/cmd/hashpw/main.go
// Small CLI helper: prints a bcrypt hash for an arbitrary plaintext password.
//
// Usage:
//
// go run ./cmd/hashpw yourSecretHere
//
// Copy the printed line into scripts/seed_data.sql when rotating demo users.
package main
import (
"fmt"
"log"
"os"
"baasid/internal/auth"
)
func main() {
if len(os.Args) < 2 {
log.Fatal("usage: go run ./cmd/hashpw <plaintext-password>")
}
plain := os.Args[1]
hash, err := auth.HashPassword(plain)
if err != nil {
log.Fatal(err)
}
fmt.Println(hash)
}
Bài viết liên quan
Go
go
Cập nhật 2026-04-18
main.go
main.go — go source code from the Go learning materials (Go/Baasid/cmd/server/main.go).
Đọc bài viết →
Go
go
Cập nhật 2026-04-18
docs.go
docs.go — go source code from the Go learning materials (Go/Baasid/docs/docs.go).
Đọc bài viết →
Go
go
Cập nhật 2026-04-18
jwt.go
jwt.go — go source code from the Go learning materials (Go/Baasid/internal/auth/jwt.go).
Đọc bài viết →
Go
go
Cập nhật 2026-04-18
password.go
password.go — go source code from the Go learning materials (Go/Baasid/internal/auth/password.go).
Đọc bài viết →
Go
go
Cập nhật 2026-04-18
password_test.go
password_test.go — go source code from the Go learning materials (Go/Baasid/internal/auth/password_test.go).
Đọc bài viết →
Go
go
Cập nhật 2026-04-18
config.go
config.go — go source code from the Go learning materials (Go/Baasid/internal/config/config.go).
Đọc bài viết →