Python uuid.uuid3() Examples

The following are 30 code examples of uuid.uuid3(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module uuid , or try the search function .
Example #1
Source Project: neo-boa   Author: CityOfZion   File: method.py    License: MIT License 8 votes vote down vote up
def __init__(self, module, block, module_name, extra):
        self.module = module
        self.block = block
        self.module_name = module_name
        self._extra = extra

        method_block_index = self.get_code_block_index(self.block)
        if method_block_index is None:
            raise Exception('Block of code of a method from %s module was not found', self.module_name)

        self.name = self.block[method_block_index + 1].arg
        self._id = uuid3(UUID('{baa187e0-2c51-4ef6-aa42-b3421c22d5e1}'), self.full_name)
        self.start_line_no = self.block[method_block_index].lineno
        self.code_object = self.block[method_block_index].arg

#        dis.dis(code_object)
        self.code, self.dictionary_defs = preprocess_method_body(self.code_object)

        self.bytecode = Bytecode.from_code(self.code)

        self.evaluate_annotations(method_block_index)
        self.setup() 
Example #2
Source Project: ironpython2   Author: IronLanguages   File: test_uuid.py    License: Apache License 2.0 6 votes vote down vote up
def test_uuid3(self):
        equal = self.assertEqual

        # Test some known version-3 UUIDs.
        for u, v in [(uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org'),
                      '6fa459ea-ee8a-3ca4-894e-db77e160355e'),
                     (uuid.uuid3(uuid.NAMESPACE_URL, 'http://python.org/'),
                      '9fe8e8c4-aaa8-32a9-a55c-4535a88b748d'),
                     (uuid.uuid3(uuid.NAMESPACE_OID, '1.3.6.1'),
                      'dd1a1cef-13d5-368a-ad82-eca71acd4cd1'),
                     (uuid.uuid3(uuid.NAMESPACE_X500, 'c=ca'),
                      '658d3002-db6b-3040-a1d1-8ddd7d189a4d'),
                    ]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 3)
            equal(u, uuid.UUID(v))
            equal(str(u), v) 
Example #3
Source Project: BinderFilter   Author: dxwu   File: test_uuid.py    License: MIT License 6 votes vote down vote up
def test_uuid3(self):
        equal = self.assertEqual

        # Test some known version-3 UUIDs.
        for u, v in [(uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org'),
                      '6fa459ea-ee8a-3ca4-894e-db77e160355e'),
                     (uuid.uuid3(uuid.NAMESPACE_URL, 'http://python.org/'),
                      '9fe8e8c4-aaa8-32a9-a55c-4535a88b748d'),
                     (uuid.uuid3(uuid.NAMESPACE_OID, '1.3.6.1'),
                      'dd1a1cef-13d5-368a-ad82-eca71acd4cd1'),
                     (uuid.uuid3(uuid.NAMESPACE_X500, 'c=ca'),
                      '658d3002-db6b-3040-a1d1-8ddd7d189a4d'),
                    ]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 3)
            equal(u, uuid.UUID(v))
            equal(str(u), v) 
Example #4
Source Project: oss-ftp   Author: aliyun   File: test_uuid.py    License: MIT License 6 votes vote down vote up
def test_uuid3(self):
        equal = self.assertEqual

        # Test some known version-3 UUIDs.
        for u, v in [(uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org'),
                      '6fa459ea-ee8a-3ca4-894e-db77e160355e'),
                     (uuid.uuid3(uuid.NAMESPACE_URL, 'http://python.org/'),
                      '9fe8e8c4-aaa8-32a9-a55c-4535a88b748d'),
                     (uuid.uuid3(uuid.NAMESPACE_OID, '1.3.6.1'),
                      'dd1a1cef-13d5-368a-ad82-eca71acd4cd1'),
                     (uuid.uuid3(uuid.NAMESPACE_X500, 'c=ca'),
                      '658d3002-db6b-3040-a1d1-8ddd7d189a4d'),
                    ]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 3)
            equal(u, uuid.UUID(v))
            equal(str(u), v) 
Example #5
Source Project: scapy   Author: secdev   File: volatile.py    License: GNU General Public License v2.0 6 votes vote down vote up
def _fix(self):
        if self.uuid_template:
            return uuid.UUID(("%08x%04x%04x" + ("%02x" * 8))
                             % self.uuid_template)
        elif self.version == 1:
            return uuid.uuid1(self.node, self.clock_seq)
        elif self.version == 3:
            return uuid.uuid3(self.namespace, self.name)
        elif self.version == 4:
            return uuid.uuid4()
        elif self.version == 5:
            return uuid.uuid5(self.namespace, self.name)
        else:
            raise ValueError("Unhandled version")


# Automatic timestamp 
Example #6
Source Project: Fluid-Designer   Author: Microvellum   File: test_uuid.py    License: GNU General Public License v3.0 6 votes vote down vote up
def test_uuid3(self):
        equal = self.assertEqual

        # Test some known version-3 UUIDs.
        for u, v in [(uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org'),
                      '6fa459ea-ee8a-3ca4-894e-db77e160355e'),
                     (uuid.uuid3(uuid.NAMESPACE_URL, 'http://python.org/'),
                      '9fe8e8c4-aaa8-32a9-a55c-4535a88b748d'),
                     (uuid.uuid3(uuid.NAMESPACE_OID, '1.3.6.1'),
                      'dd1a1cef-13d5-368a-ad82-eca71acd4cd1'),
                     (uuid.uuid3(uuid.NAMESPACE_X500, 'c=ca'),
                      '658d3002-db6b-3040-a1d1-8ddd7d189a4d'),
                    ]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 3)
            equal(u, uuid.UUID(v))
            equal(str(u), v) 
Example #7
Source Project: ironpython3   Author: IronLanguages   File: test_uuid.py    License: Apache License 2.0 6 votes vote down vote up
def test_uuid3(self):
        equal = self.assertEqual

        # Test some known version-3 UUIDs.
        for u, v in [(uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org'),
                      '6fa459ea-ee8a-3ca4-894e-db77e160355e'),
                     (uuid.uuid3(uuid.NAMESPACE_URL, 'http://python.org/'),
                      '9fe8e8c4-aaa8-32a9-a55c-4535a88b748d'),
                     (uuid.uuid3(uuid.NAMESPACE_OID, '1.3.6.1'),
                      'dd1a1cef-13d5-368a-ad82-eca71acd4cd1'),
                     (uuid.uuid3(uuid.NAMESPACE_X500, 'c=ca'),
                      '658d3002-db6b-3040-a1d1-8ddd7d189a4d'),
                    ]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 3)
            equal(u, uuid.UUID(v))
            equal(str(u), v) 
Example #8
Source Project: gcblue   Author: gcblue   File: test_uuid.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_uuid3(self):
        equal = self.assertEqual

        # Test some known version-3 UUIDs.
        for u, v in [(uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org'),
                      '6fa459ea-ee8a-3ca4-894e-db77e160355e'),
                     (uuid.uuid3(uuid.NAMESPACE_URL, 'http://python.org/'),
                      '9fe8e8c4-aaa8-32a9-a55c-4535a88b748d'),
                     (uuid.uuid3(uuid.NAMESPACE_OID, '1.3.6.1'),
                      'dd1a1cef-13d5-368a-ad82-eca71acd4cd1'),
                     (uuid.uuid3(uuid.NAMESPACE_X500, 'c=ca'),
                      '658d3002-db6b-3040-a1d1-8ddd7d189a4d'),
                    ]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 3)
            equal(u, uuid.UUID(v))
            equal(str(u), v) 
Example #9
Source Project: Project-New-Reign---Nemesis-Main   Author: ShikyoKira   File: test_uuid.py    License: GNU General Public License v3.0 6 votes vote down vote up
def test_uuid3(self):
        equal = self.assertEqual

        # Test some known version-3 UUIDs.
        for u, v in [(uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org'),
                      '6fa459ea-ee8a-3ca4-894e-db77e160355e'),
                     (uuid.uuid3(uuid.NAMESPACE_URL, 'http://python.org/'),
                      '9fe8e8c4-aaa8-32a9-a55c-4535a88b748d'),
                     (uuid.uuid3(uuid.NAMESPACE_OID, '1.3.6.1'),
                      'dd1a1cef-13d5-368a-ad82-eca71acd4cd1'),
                     (uuid.uuid3(uuid.NAMESPACE_X500, 'c=ca'),
                      '658d3002-db6b-3040-a1d1-8ddd7d189a4d'),
                    ]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 3)
            equal(u, uuid.UUID(v))
            equal(str(u), v) 
Example #10
Source Project: medicare-demo   Author: ofermend   File: test_uuid.py    License: Apache License 2.0 6 votes vote down vote up
def test_uuid3(self):
        equal = self.assertEqual

        # Test some known version-3 UUIDs.
        for u, v in [(uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org'),
                      '6fa459ea-ee8a-3ca4-894e-db77e160355e'),
                     (uuid.uuid3(uuid.NAMESPACE_URL, 'http://python.org/'),
                      '9fe8e8c4-aaa8-32a9-a55c-4535a88b748d'),
                     (uuid.uuid3(uuid.NAMESPACE_OID, '1.3.6.1'),
                      'dd1a1cef-13d5-368a-ad82-eca71acd4cd1'),
                     (uuid.uuid3(uuid.NAMESPACE_X500, 'c=ca'),
                      '658d3002-db6b-3040-a1d1-8ddd7d189a4d'),
                    ]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 3)
            equal(u, uuid.UUID(v))
            equal(str(u), v) 
Example #11
Source Project: CTFCrackTools-V2   Author: Acmesec   File: test_uuid.py    License: GNU General Public License v3.0 6 votes vote down vote up
def test_uuid3(self):
        equal = self.assertEqual

        # Test some known version-3 UUIDs.
        for u, v in [(uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org'),
                      '6fa459ea-ee8a-3ca4-894e-db77e160355e'),
                     (uuid.uuid3(uuid.NAMESPACE_URL, 'http://python.org/'),
                      '9fe8e8c4-aaa8-32a9-a55c-4535a88b748d'),
                     (uuid.uuid3(uuid.NAMESPACE_OID, '1.3.6.1'),
                      'dd1a1cef-13d5-368a-ad82-eca71acd4cd1'),
                     (uuid.uuid3(uuid.NAMESPACE_X500, 'c=ca'),
                      '658d3002-db6b-3040-a1d1-8ddd7d189a4d'),
                    ]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 3)
            equal(u, uuid.UUID(v))
            equal(str(u), v) 
Example #12
Source Project: CTFCrackTools   Author: Acmesec   File: test_uuid.py    License: GNU General Public License v3.0 6 votes vote down vote up
def test_uuid3(self):
        equal = self.assertEqual

        # Test some known version-3 UUIDs.
        for u, v in [(uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org'),
                      '6fa459ea-ee8a-3ca4-894e-db77e160355e'),
                     (uuid.uuid3(uuid.NAMESPACE_URL, 'http://python.org/'),
                      '9fe8e8c4-aaa8-32a9-a55c-4535a88b748d'),
                     (uuid.uuid3(uuid.NAMESPACE_OID, '1.3.6.1'),
                      'dd1a1cef-13d5-368a-ad82-eca71acd4cd1'),
                     (uuid.uuid3(uuid.NAMESPACE_X500, 'c=ca'),
                      '658d3002-db6b-3040-a1d1-8ddd7d189a4d'),
                    ]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 3)
            equal(u, uuid.UUID(v))
            equal(str(u), v) 
Example #13
Source Project: arches   Author: archesproject   File: skos.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
def generate_uuid_from_subject(self, baseuuid, subject):
        uuidregx = re.compile(r"[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}")
        matches = uuidregx.search(str(subject))
        if matches:
            return matches.group(0)
        else:
            return str(uuid.uuid3(baseuuid, str(subject))) 
Example #14
Source Project: python-mysql-pool   Author: LuciferJack   File: connection.py    License: MIT License 5 votes vote down vote up
def _fabric_server_uuid(host, port):
    """Create a UUID using host and port"""
    return uuid.uuid3(uuid.NAMESPACE_URL, _fabric_xmlrpc_uri(host, port)) 
Example #15
Source Project: CGIShell   Author: cj1324   File: cgishell.py    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
def __init__(self, url):
        self.fullurl = self._complete_url(url)
        uinfo = urlparse.urlparse(self.fullurl)
        pext = os.path.splitext(uinfo.path)
        if len(pext) == 2 and pext[1] not in ('.cgi', '.sh'):
            warnings.warn("Recommended suffix CGI!")

        self.host = uinfo.hostname
        self.uuid = uuid.uuid3(uuid.NAMESPACE_DNS, 'hanchen.me').hex
        self.user = 'unknown'
        self._init_opener() 
Example #16
Source Project: thenextquant   Author: SimoHaiLiu   File: tools.py    License: MIT License 5 votes vote down vote up
def get_uuid3(str_in):
    """ make a UUID using an MD5 hash of a namespace UUID and a name
    @param str_in 输入字符串
    """
    s = uuid.uuid3(uuid.NAMESPACE_DNS, str_in)
    return str(s) 
Example #17
Source Project: aioquant   Author: JiaoziMatrix   File: tools.py    License: MIT License 5 votes vote down vote up
def get_uuid3(str_in):
    """Generate a UUID using an MD5 hash of a namespace UUID and a name

    Args:
        str_in: Input string.

    Returns:
        s: UUID3 string.
    """
    uid3 = uuid.uuid3(uuid.NAMESPACE_DNS, str_in)
    s = str(uid3)
    return s 
Example #18
Source Project: PyEngine3D   Author: ubuntunux   File: ResourceManager.py    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
def generate_material_name(shader_name, macros=None):
        if macros is not None and 0 < len(macros):
            keys = sorted(macros.keys())
            add_name = [key + "_" + str(macros[key]) for key in keys]
            shader_name += "_" + str(uuid.uuid3(uuid.NAMESPACE_DNS, "_".join(add_name))).replace("-", "_")
        return shader_name 
Example #19
Source Project: Code-Confuse-Plugin   Author: LennonChin   File: Confuse.py    License: MIT License 5 votes vote down vote up
def confuse_text(text):
        seeds = 'abcdefghijklmnopqrst'
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, text))
        uid = "".join(uid.split('-'))
        result = ""
        for c in uid:
            try:
                num = int(c)
                result += seeds[num]
            except Exception as e:
                result += c
        return result.upper()

    # 生成混淆文件 
Example #20
Source Project: Code-Confuse-Plugin   Author: LennonChin   File: Confuse.py    License: MIT License 5 votes vote down vote up
def confuse_text(text):
        seeds = 'abcdefghijklmnopqrst'
        uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, text))
        uid = "".join(uid.split('-'))
        result = ""
        for c in uid:
            try:
                num = int(c)
                result += seeds[num]
            except Exception as e:
                result += c
        return result.upper()

    # 生成混淆文件 
Example #21
Source Project: AnyBlok   Author: AnyBlok   File: test_column.py    License: Mozilla Public License 2.0 5 votes vote down vote up
def test_uuid_binary_3(self):
        from uuid import uuid3, NAMESPACE_DNS
        uuid = uuid3(NAMESPACE_DNS, 'python.org')
        registry = self.init_registry(simple_column, ColumnType=UUID)
        test = registry.Test.insert(col=uuid)
        assert test.col is uuid 
Example #22
Source Project: flex   Author: pipermerriam   File: test_format_validators.py    License: MIT License 5 votes vote down vote up
def test_uuid3_matches():
    for _ in range(100):
        uuid_format_validator(str(uuid.uuid3(uuid.uuid4(), 'test-4')))
        uuid_format_validator(str(uuid.uuid3(uuid.uuid1(), 'test-1'))) 
Example #23
Source Project: thenextquant   Author: TheNextQuant   File: tools.py    License: MIT License 5 votes vote down vote up
def get_uuid3(str_in):
    """ make a UUID using an MD5 hash of a namespace UUID and a name
    @param str_in 输入字符串
    """
    s = uuid.uuid3(uuid.NAMESPACE_DNS, str_in)
    return str(s) 
Example #24
Source Project: io_three   Author: repsac   File: utilities.py    License: MIT License 5 votes vote down vote up
def id_from_name(name):
    """Generate a UUID using a name as the namespace

    :type name: str
    :rtype: str

    """
    return str(uuid.uuid3(uuid.NAMESPACE_DNS, name)).upper() 
Example #25
Source Project: scalyr-agent-2   Author: scalyr   File: util.py    License: Apache License 2.0 5 votes vote down vote up
def create_uuid3(namespace, name):
    """
    Return new UUID based on a hash of a UUID namespace and a string.
    :param namespace: The namespace
    :param name: The string
    :type namespace: uuid.UUID
    :type name: six.text
    :return:
    :rtype: uuid.UUID
    """
    return uuid.uuid3(namespace, six.ensure_str(name)) 
Example #26
Source Project: code   Author: ActiveState   File: recipe-501148.py    License: MIT License 5 votes vote down vote up
def generateUuid(self, email_id, machine_name):
        """ return a uuid which uniquely identifies machinename and email id """
        uuidstr = None

        if machine_name not in self.d:
            myNamespace = uuid.uuid3(uuid.NAMESPACE_URL, machine_name)
            uuidstr = str(uuid.uuid3(myNamespace, email_id)) 

            self.d[machine_name] = (machine_name, uuidstr, email_id)
            self.d[uuidstr] = (machine_name, uuidstr ,email_id)
        else:
            (machine_name, uuidstr, email_id) = self.d[machine_name]

        return uuidstr 
Example #27
Source Project: ahenk   Author: Pardus-LiderAhenk   File: registration.py    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
def generate_uuid(self, depend_mac=True):
        if depend_mac is False:
            self.logger.debug('uuid creating randomly')
            return uuid.uuid4()  # make a random UUID
        else:
            self.logger.debug('uuid creating according to mac address')
            return uuid.uuid3(uuid.NAMESPACE_DNS,
                              str(get_mac()))  # make a UUID using an MD5 hash of a namespace UUID and a mac address 
Example #28
Source Project: ahenk   Author: Pardus-LiderAhenk   File: registration.py    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
def generate_uuid(self, depend_mac=True):
        if depend_mac is False:
            self.logger.debug('uuid creating randomly')
            return uuid.uuid4()  # make a random UUID
        else:
            self.logger.debug('uuid creating according to mac address')
            return uuid.uuid3(uuid.NAMESPACE_DNS,
                              str(get_mac()))  # make a UUID using an MD5 hash of a namespace UUID and a mac address 
Example #29
Source Project: W.I.L.L   Author: ironman5366   File: tools.py    License: MIT License 5 votes vote down vote up
def get_user_token(username):
    """
    Get a customized user token to store encrypted in the cookies

    :param username:
    :return user_token:
    """
    user_uid = uuid.uuid3(uuid.NAMESPACE_DNS, str(username))
    gen_uid = uuid.uuid1()
    return str(gen_uid)+":u:"+str(user_uid) 
Example #30
Source Project: pymobiledevice   Author: iOSForensics   File: lockdown.py    License: GNU General Public License v3.0 5 votes vote down vote up
def generate_hostID(self):
        hostname = platform.node()
        hostid = uuid.uuid3(uuid.NAMESPACE_DNS, hostname)
        return str(hostid).upper()