mirror of
https://github.com/chylex/SMTP-Relay.git
synced 2024-12-04 14:42:49 +01:00
009ae8f73a
This makes for a better user experience than a go segfault.
23 lines
390 B
Go
23 lines
390 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"golang.org/x/crypto/bcrypt"
|
|
)
|
|
|
|
func main() {
|
|
if len(os.Args) != 2 {
|
|
fmt.Fprintln(os.Stderr, "Usage: hasher PASSWORD")
|
|
os.Exit(1)
|
|
}
|
|
password := os.Args[1]
|
|
|
|
hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
|
|
if err != nil {
|
|
fmt.Fprintln(os.Stderr, "Error generating hash: %s", err)
|
|
}
|
|
fmt.Println(string(hash))
|
|
}
|