// NewNameBasedSHA1 returns a new name based UUID with SHA1 hash (version 5).
160962
func NewNameBasedSHA1(namespace, name string) (UUID, error) {
	u, err := sha1.NewUUID(namespace, name)
	if err != nil {
		return Nil, err
	}

	uuid := UUID{}
	copy(uuid[:], u)

	return uuid, nil
}
1179738
func NewEdgeHostname(edgeHostnames *EdgeHostnames) *EdgeHostname {
	edgeHostname := &EdgeHostname{parent: edgeHostnames}
	edgeHostname.Init()
	return edgeHostname
}
489960
func NewHash(newHash []byte) (*Hash, error) {
	var sh Hash
	err := sh.SetBytes(newHash)
	if err != nil {
		return nil, err
	}
	return &sh, err
}
1171694
func NewNamedType(name string) *NamedType {
	return &NamedType{token.NoPos, name, nil, true, make(map[string]Method)}
}
1146577
func (g *rfc4122Generator) NewV3(ns UUID, name string) UUID {
	u := newFromHash(md5.New(), ns, name)
	u.SetVersion(V3)
	u.SetVariant(VariantRFC4122)

	return u
}
1226937
func newUUID() (string, error) {
	uuid := make([]byte, 16)
	if _, err := io.ReadFull(rand.Reader, uuid); err != nil {
		return "", err
	}
	// variant bits; see section 4.1.1
	uuid[8] = uuid[8]&^0xc0 | 0x80
	// version 4 (pseudo-random); see section 4.1.3
	uuid[6] = uuid[6]&^0xf0 | 0x40
	return fmt.Sprintf("%x-%x-%x-%x-%x", uuid[0:4], uuid[4:6], uuid[6:8], uuid[8:10], uuid[10:]), nil
}
516095
func NewFromHash(hashedKey string) (Crypter, error) {
	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]
	}

	if f != nil {
		return f(), nil
	}

	return nil, errors.New("Invalid hash")
}
592105
func NewUUIDByHex(source string) (UUID, error) {
	uuid := UUID{}
	if len([]byte(source)) != 32 {
		return uuid, errors.New(ErrInvalidHexLength, errorMessages)
	}
	raw, err := hex.DecodeString(source)
	if err != nil {
		return uuid, errors.Annotate(err, ErrInvalidHexValue, errorMessages)
	}
	copy(uuid[:], raw)
	return uuid, nil
}
1194783
func NewName(Parts []node.Node) *Name {
	return &Name{
		FreeFloating: nil,
		Parts:        Parts,
	}
}
223487
func NewNamedCRS(name string) *CRS {
	return &CRS{Type: "name", Properties: map[string]string{"name": name}}
}
287993
func NewIdentityMapping(username, groupname string) (*IdentityMapping, error) {
	subuidRanges, err := parseSubuid(username)
	if err != nil {
		return nil, err
	}
	subgidRanges, err := parseSubgid(groupname)
	if err != nil {
		return nil, err
	}
	if len(subuidRanges) == 0 {
		return nil, fmt.Errorf("No subuid ranges found for user %q", username)
	}
	if len(subgidRanges) == 0 {
		return nil, fmt.Errorf("No subgid ranges found for group %q", groupname)
	}

	return &IdentityMapping{
		uids: createIDMap(subuidRanges),
		gids: createIDMap(subgidRanges),
	}, nil
}
1182180
func newFromHash(h hash.Hash, ns UUID, name string) UUID {
	u := UUID{}
	h.Write(ns[:])
	h.Write([]byte(name))
	copy(u[:], h.Sum(nil))

	return u
}
712721
func NewHash(name string, m map[string]string) (Vindex, error) {
	return &Hash{name: name}, nil
}
812911
func NewACName(s string) (*ACName, error) {
	n := ACName(s)
	if err := n.assertValid(); err != nil {
		return nil, err
	}
	return &n, nil
}
778744
func (s *SSHService) NewDeleteSSHKeyPairParams(name string) *DeleteSSHKeyPairParams {
	p := &DeleteSSHKeyPairParams{}
	p.p = make(map[string]interface{})
	p.p["name"] = name
	return p
}
1032315
func CryptoHashToDigestName(id crypto.Hash) (result string, err error) {
	var supported bool
	if result, supported = algorithmName[id]; !supported {
		err = errors.New("hmacauth: unsupported crypto.Hash #" +
			strconv.Itoa(int(id)))
	}
	return
}
1132901
func NewBase(n string) *Base {
	return &Base{
		name:       n,
		reset:      func() {},
		closer:     func() error { return nil },
		errHandler: func(error, message.Composer) {},
	}
}