// NewNameBasedMD5 returns a new name based UUID with MD5 hash (version 3).
505984
func NewNameBasedMD5(namespace, name string) (UUID, error) {
	u, err := md5.NewUUID(namespace, name)
	if err != nil {
		return Nil, err
	}

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

	return uuid, nil
}
1336316
func NewNamedSchema(name string, value *Schema) *NamedSchema {
	return &NamedSchema{Name: name, Value: value}
}
452617
func (c *client) idToName(s string) string {
	return idToName(s, c.hash)
}
705558
func NewUUIDv4() (UUID, error) {
	uuid := UUID{}
	_, err := rand.Read([]byte(uuid[:]))
	if err != nil {
		return uuid, err
	}

	uuid.setVersion(UUIDv4)
	uuid.setVariant(UUIDVariantRFC4122)
	return uuid, nil
}
1194783
func NewName(Parts []node.Node) *Name {
	return &Name{
		FreeFloating: nil,
		Parts:        Parts,
	}
}
506919
func (s *Stack) CreateNamedNIC(id tcpip.NICID, name string, linkEP tcpip.LinkEndpointID) *tcpip.Error {
	return s.createNIC(id, name, linkEP, true, false)
}
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
}
390180
func (o *Generator) NewHash(hash hash.Hash, names ...interface{}) UUID {
	id := UUID{}
	id.unmarshal(digest(hash, []byte{}, names...))
	id[versionIndex] &= 0x0f
	id[versionIndex] |= uint8(0 << 4)
	id[variantIndex] &= variantSet
	id[variantIndex] |= VariantFuture
	return id
}
272587
func NewRandomEntityWithName(name string) (e Entity, err error) {
	var public []byte
	var private []byte

	public, private, err = generateKeyPairs()
	if err == nil && len(public) > 0 && len(private) > 0 {
		e = NewEntity(name, public, private)
	}

	return
}
1124032
func NewBaseType(init ...interface{}) BaseType {
	if len(init) == 1 {
		switch v := init[0].(type) {
		case BaseType:
			return v
		case int:
			return BaseType(v)
		case int32:
			return BaseType(v)
		case string:
			for i, s := range namesBaseType {
				if s == v {
					return BaseType(i)
				}
			}
		default:
			panic("Bad init value for BaseType enum")
		}
	}
	return BaseType(0) //default to the first enum value
}
722716
func NewNamespace(modelUUID string) (Namespace, error) {
	if !names.IsValidModel(modelUUID) {
		return nil, errors.Errorf("model ID %q is not a valid model", modelUUID)
	}
	// The suffix is the last six hex digits of the model uuid.
	suffix := modelUUID[len(modelUUID)-uuidSuffixDigits:]

	return &namespace{name: suffix}, nil
}
1261997
func NewNamedUlimitOpt(name string, ref *map[string]*units.Ulimit) *NamedUlimitOpt {
	if ref == nil {
		ref = &map[string]*units.Ulimit{}
	}
	return &NamedUlimitOpt{
		name:      name,
		UlimitOpt: *NewUlimitOpt(ref),
	}
}
597697
func NewNamedTree(name string, input io.Reader) *Tree {
	return &Tree{
		lex: newLexer(input),

		root:   NewModuleNode(name),
		blocks: []map[string]*BlockNode{make(map[string]*BlockNode)},
		macros: make(map[string]*MacroNode),

		unread: make([]token, 0),
		read:   make([]token, 0),

		Name:     name,
		Visitors: make([]NodeVisitor, 0),
	}
}
90566
func NewV5(ns *UUID, name []byte) (u *UUID, err error) {
	u = new(UUID)
	// Set all bits to truncated SHA1 hash generated from namespace
	// and name.
	u.setBytesFromHash(sha1.New(), ns[:], name)
	u.setVariant(ReservedRFC4122)
	u.setVersion(5)
	return
}
1094760
func (o *Generator) NewV3(namespace Implementation, names ...interface{}) UUID {
	id := UUID{}
	id.unmarshal(digest(md5.New(), namespace.Bytes(), names...))
	id.setRFC4122Version(VersionThree)
	return id
}
570043
func newVersionedDB(couchInstance *couchdb.CouchInstance, dbName string) (*VersionedDB, error) {
	// CreateCouchDatabase creates a CouchDB database object, as well as the underlying database if it does not exist
	chainName := dbName
	dbName = couchdb.ConstructMetadataDBName(dbName)

	metadataDB, err := couchdb.CreateCouchDatabase(couchInstance, dbName)
	if err != nil {
		return nil, err
	}
	namespaceDBMap := make(map[string]*couchdb.CouchDatabase)
	return &VersionedDB{
		couchInstance:      couchInstance,
		metadataDB:         metadataDB,
		chainName:          chainName,
		namespaceDBs:       namespaceDBMap,
		committedDataCache: newVersionCache(),
		lsccStateCache: &lsccStateCache{
			cache: make(map[string]*statedb.VersionedValue),
		},
	}, nil
}
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
}