Esempio n. 1
0
// Write hash to file
func WriteHash(password string, filename string) (err error) {
	ph := pbkdf2.HashPassword(password)

	phOut := make([]byte, 0)
	phOut = append(phOut, ph.Salt...)
	phOut = append(phOut, ph.Hash...)

	err = ioutil.WriteFile(filename, phOut, 0600)
	return
}
Esempio n. 2
0
func testAuthProvider(user interface{}) (salt, hash []byte) {
	hash = []byte{}
	salt = []byte{}
	switch user.(type) {
	default:
		return
	case string:
		break
	}

	if user != "user" {
		return
	}
	ph := pbkdf2.HashPassword(test_password)
	hash = ph.Hash
	salt = ph.Salt
	return
}
Esempio n. 3
0
// HashPass is provided to return a salt and string for a password.
func HashPass(password string) (salt, hash []byte) {
	ph := pbkdf2.HashPassword(password)
	hash = ph.Hash
	salt = ph.Salt
	return
}