如何从“域名”和“对象名”创建UUID?

2024-04-23 11:37:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我一定误解了Python的uuid模块,或者the RFC for generating UUIDs

如何使用域名和对象名生成UUID3字符串?在

see“版本3 UUID是从一个限定的名称空间生成的,比如URL或域名以及对象id或名称。”

但是,在python.org网站is表示用法是uuid.uuid3(namespace, name)。既然这里的“namespace”应该指定“name”的类型,那么我应该如何同时指定“domain name”和“object name”?在


Tags: 模块the对象字符串name名称foruuid
1条回答
网友
1楼 · 发布于 2024-04-23 11:37:41

来自RFC的section 4.3

The version 3 or 5 UUID is meant for generating UUIDs from "names" that are drawn from, and unique within, some "name space". The concept of name and name space should be broadly construed, and not limited to textual names. For example, some name spaces are the domain name system, URLs, ISO Object IDs (OIDs), X.500 Distinguished Names (DNs), and reserved words in a programming language.

因此,UUID3接受名称空间标识符(UUID)和名称。不是域名和对象名。如果您使用域名作为名称,请使用^{} UUID。在

相关问题 更多 >