blob: dabafa75fc7309fc6a002477cbcfcc099361a5fa (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
package main
import (
"os"
"golang.org/x/crypto/argon2"
"golang.org/x/term"
)
const defaultArgon2Memory = 64 * 1024
func hashPassword(password string, salt []byte, memory int) ([]byte, error) {
return argon2.IDKey([]byte(password), salt, 1, uint32(memory), 4, 32), nil
}
func termReadPassword() (string, error) {
pw, err := term.ReadPassword(int(os.Stdin.Fd()))
if err != nil {
return "", err
}
return string(pw), nil
}
|