user/crypt/crypt.go
func NewFromHash(hashedKey string) Crypter {
	var f func() Crypter

	if strings.HasPrefix(hashedKey, cryptPrefixes[SHA512]) {
		f = crypts[SHA512]
	} else if strings.HasPrefix(hashedKey, cryptPrefixes[SHA256]) {
		f = crypts[SHA256]
	} else if strings.HasPrefix(hashedKey, cryptPrefixes[MD5]) {
		f = crypts[MD5]
	} else if strings.HasPrefix(hashedKey, cryptPrefixes[APR1]) {
		f = crypts[APR1]
	} else {
		toks := strings.SplitN(hashedKey, "$", 3)
		prefix := "$" + toks[1] + "$"
		panic("crypt: unknown cryp function from prefix: " + prefix)
	}

	if f != nil {
		return f()
	}
	panic("crypt: requested cryp function is unavailable")
}
func NewFromHash(hashedKey string) Crypter {
	var f func() Crypter

	if strings.HasPrefix(hashedKey, cryptPrefixes[SHA512]) {
		f = crypts[SHA512]
	} else if strings.HasPrefix(hashedKey, cryptPrefixes[SHA256]) {
		f = crypts[SHA256]
	} else if strings.HasPrefix(hashedKey, cryptPrefixes[MD5]) {
		f = crypts[MD5]
	} else if strings.HasPrefix(hashedKey, cryptPrefixes[APR1]) {
		f = crypts[APR1]
	} else {
		toks := strings.SplitN(hashedKey, "$", 3)
		prefix := "$" + toks[1] + "$"
		panic("crypt: unknown cryp function from prefix: " + prefix)
	}

	if f != nil {
		return f()
	}
	panic("crypt: requested cryp function is unavailable")
}
func NewFromHash ( hashedKey string ) Crypter { var f func ( ) Crypter if strings . HasPrefix ( hashedKey , cryptPrefixes [ SHA512 ] ) { f = crypts [ SHA512 ] } else if strings . HasPrefix ( hashedKey , cryptPrefixes [ SHA256 ] ) { f = crypts [ SHA256 ] } else if strings . HasPrefix ( hashedKey , cryptPrefixes [ MD5 ] ) { f = crypts [ MD5 ] } else if strings . HasPrefix ( hashedKey , cryptPrefixes [ APR1 ] ) { f = crypts [ APR1 ] } else { toks := strings . SplitN ( hashedKey , " " , 3 ) prefix := " " + toks [ 1 ] + " " panic ( " " + prefix ) } if f != nil { return f ( ) } panic ( " " ) }
// NewFromHash returns a new Crypter using the prefix in the given hashed key.
NewFromHash returns a new Crypter using the prefix in the given hashed key .