當前位置: 首頁>>代碼示例>>Python>>正文


Python string.hexdigits方法代碼示例

本文整理匯總了Python中string.hexdigits方法的典型用法代碼示例。如果您正苦於以下問題:Python string.hexdigits方法的具體用法?Python string.hexdigits怎麽用?Python string.hexdigits使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在string的用法示例。


在下文中一共展示了string.hexdigits方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: api_config

# 需要導入模塊: import string [as 別名]
# 或者: from string import hexdigits [as 別名]
def api_config():
    """Request API config from user and set"""
    code, hash_value = DIALOG.inputbox("Enter your API Hash")
    if code == DIALOG.OK:
        if len(hash_value) != 32 or any(it not in string.hexdigits for it in hash_value):
            DIALOG.msgbox("Invalid hash")
            return
        string1 = "HASH = \"" + hash_value + "\""
        code, id_value = DIALOG.inputbox("Enter your API ID")
        if not id_value or any(it not in string.digits for it in id_value):
            DIALOG.msgbox("Invalid ID")
            return
        string2 = "ID = \"" + id_value + "\""
        with open(os.path.join(utils.get_base_dir(), "api_token.py"), "w") as file:
            file.write(string1 + "\n" + string2 + "\n")
        DIALOG.msgbox("API Token and ID set.") 
開發者ID:friendly-telegram,項目名稱:friendly-telegram,代碼行數:18,代碼來源:configurator.py

示例2: s_hexlit

# 需要導入模塊: import string [as 別名]
# 或者: from string import hexdigits [as 別名]
def s_hexlit(s, t):
  if s.peek(2, True) != '0x':
    return False

  s.get()
  s.get()

  lit = ""
  while not s.empty() and s.peek() in string.hexdigits:
    lit += s.get()

  if not lit:
    return False

  t.append((TokenTypes.LITERAL_INT, int(lit, 16)))
  return True 
開發者ID:gynvael,項目名稱:stream,代碼行數:18,代碼來源:casm.py

示例3: s_hexlit

# 需要導入模塊: import string [as 別名]
# 或者: from string import hexdigits [as 別名]
def s_hexlit(s, t):
  if s.peek(2, True) != '0x':
    return False

  s.get()
  s.get()

  lit = ""
  while not s.empty() and s.peek() in string.hexdigits:
    lit += s.get()

  if not lit:
    return False

  t.append(int(lit, 16))
  return True 
開發者ID:gynvael,項目名稱:stream,代碼行數:18,代碼來源:casm.py

示例4: post

# 需要導入模塊: import string [as 別名]
# 或者: from string import hexdigits [as 別名]
def post(self, digest):
        """
        Create a running instance from the container image digest
        """
        # Containers are mapped to teams
        user_account = api.user.get_user()
        tid = user_account['tid']

        # fail fast on invalid requests
        if any(char not in string.hexdigits + "sha:" for char in digest):
            raise PicoException("Invalid image digest", 400)

        # Create the container
        result = api.docker.create(tid, digest)

        return jsonify({"success": result['success'], "message": result['message']}) 
開發者ID:picoCTF,項目名稱:picoCTF,代碼行數:18,代碼來源:docker.py

示例5: delete

# 需要導入模塊: import string [as 別名]
# 或者: from string import hexdigits [as 別名]
def delete(self, digest, container_id):
        """
        Stop a running container.
        """

        # fail fast on invalid requests
        if any(char not in string.hexdigits for char in container_id):
            raise PicoException("Invalid container ID", 400)

        # Delete the container
        result = api.docker.delete(container_id)

        if result:
            return jsonify({"success": True, "message": "Challenge stopped"})
        else:
            return jsonify({"success": False, "message": "Error stopping challenge"}) 
開發者ID:picoCTF,項目名稱:picoCTF,代碼行數:18,代碼來源:docker.py

示例6: isHex

# 需要導入模塊: import string [as 別名]
# 或者: from string import hexdigits [as 別名]
def isHex(val: str) -> bool:
    """
    Return whether the given str represents a hex value or not

    :param val: the string to check
    :return: whether the given str represents a hex value
    """
    if isinstance(val, bytes):
        # only decodes utf-8 string
        try:
            val = val.decode()
        except ValueError:
            return False
    return isinstance(val, str) and all(c in string.hexdigits for c in val)

# decorator 
開發者ID:hyperledger,項目名稱:indy-plenum,代碼行數:18,代碼來源:utils.py

示例7: check_wildcard

# 需要導入模塊: import string [as 別名]
# 或者: from string import hexdigits [as 別名]
def check_wildcard(res, domain_trg):
    """
    Function for checking if Wildcard resolution is configured for a Domain
    """
    wildcard = None
    test_name = ''.join(Random().sample(string.hexdigits + string.digits,
                                        12)) + '.' + domain_trg
    ips = res.get_a(test_name)

    if len(ips) > 0:
        print_debug('Wildcard resolution is enabled on this domain')
        print_debug('It is resolving to {0}'.format(''.join(ips[0][2])))
        print_debug("All queries will resolve to this address!!")
        wildcard = ''.join(ips[0][2])

    return wildcard 
開發者ID:Yukinoshita47,項目名稱:Yuki-Chan-The-Auto-Pentest,代碼行數:18,代碼來源:dnsrecon.py

示例8: __init__

# 需要導入模塊: import string [as 別名]
# 或者: from string import hexdigits [as 別名]
def __init__(self, crawler, persister, logger, attack_options):
        Attack.__init__(self, crawler, persister, logger, attack_options)
        empty_func = "() { :;}; "

        self.rand_string = "".join([random.choice(string.hexdigits) for _ in range(32)])
        hex_string = hexlify(self.rand_string.encode())
        bash_string = ""
        for i in range(0, 64, 2):
            bash_string += "\\x" + hex_string[i:i+2].decode()

        cmd = "echo; echo; echo -e '{0}';".format(bash_string)

        self.hdrs = {
            "user-agent": empty_func + cmd,
            "referer": empty_func + cmd,
            "cookie": empty_func + cmd
        } 
開發者ID:penetrate2hack,項目名稱:ITWSV,代碼行數:19,代碼來源:mod_shellshock.py

示例9: callback

# 需要導入模塊: import string [as 別名]
# 或者: from string import hexdigits [as 別名]
def callback(self, stream):
        data = str(stream).replace(" ", "").strip()

        if '0:' in data:
            return

        if len(data) > 16:
            print "Frame length error : ", data
            return

        if not all(c in string.hexdigits for c in data):
            print _("Frame hex error : "), data
            return

        data = data.replace(' ', '').ljust(16, "0")

        if self.currentrequest:
            values = self.currentrequest.get_values_from_stream(data)
            i = 0
            for name in self.names:
                if name in values:
                    value = values[name]
                    if value is not None:
                        self.table.item(i, 0).setText(value)
                i += 1 
開發者ID:cedricp,項目名稱:ddt4all,代碼行數:27,代碼來源:sniffer.py

示例10: step_size_start

# 需要導入模塊: import string [as 別名]
# 或者: from string import hexdigits [as 別名]
def step_size_start(self, char):
        if char in string.hexdigits:
            return self._add_size_char(char, start=True)
        if ' ' == char:
            return self.STATUS_AFTER_SIZE
        if '\t' == char:
            self.setError(self.ERROR_BAD_SPACE, critical=False)
            return self.STATUS_AFTER_SIZE
        if ';' == char:
            return self.STATUS_TRAILER
        if '\r' == char:
            self.eof += u'[CR]'
            return self.STATUS_AFTER_CR
        if '\n' == char:
            self.setError(self.ERROR_LF_WITHOUT_CR, critical=False)
            self.eof += u'[LF]'
            return self.STATUS_END
        # other chars are bad
        self.setError(self.ERROR_BAD_CHUNK_HEADER)
        return self.STATUS_END 
開發者ID:regilero,項目名稱:HTTPWookiee,代碼行數:22,代碼來源:chunk.py

示例11: step_size

# 需要導入模塊: import string [as 別名]
# 或者: from string import hexdigits [as 別名]
def step_size(self, char):
        if char in string.hexdigits:
            return self._add_size_char(char)
        if ' ' == char:
            return self.STATUS_AFTER_SIZE
        if '\t' == char:
            self.setError(self.ERROR_BAD_SPACE, critical=False)
            return self.STATUS_AFTER_SIZE
        if ';' == char:
            return self.STATUS_TRAILER
        if '\r' == char:
            self.eof += u'[CR]'
            return self.STATUS_AFTER_CR
        if '\n' == char:
            self.setError(self.ERROR_LF_WITHOUT_CR, critical=False)
            self.eof += u'[LF]'
            return self.STATUS_END
        # other chars are bad
        self.setError(self.ERROR_BAD_CHUNK_HEADER)
        return self.STATUS_END 
開發者ID:regilero,項目名稱:HTTPWookiee,代碼行數:22,代碼來源:chunk.py

示例12: OnChar

# 需要導入模塊: import string [as 別名]
# 或者: from string import hexdigits [as 別名]
def OnChar(self, event):
        key = event.GetKeyCode()

        if wx.WXK_SPACE == key or chr(key) in string.hexdigits:
            value = event.GetEventObject().GetValue() + chr(key)
            if apduregexp.match(value):
                event.Skip()
            return

        if key < wx.WXK_SPACE or key == wx.WXK_DELETE or key > 255:
            event.Skip()
            return

        if not wx.Validator_IsSilent():
            wx.Bell()

        return 
開發者ID:LudovicRousseau,項目名稱:pyscard,代碼行數:19,代碼來源:APDUHexValidator.py

示例13: parse_char

# 需要導入模塊: import string [as 別名]
# 或者: from string import hexdigits [as 別名]
def parse_char(txt):
	if not txt:raise PreprocError("attempted to parse a null char")
	if txt[0]!='\\':
		return ord(txt)
	c=txt[1]
	if c=='x':
		if len(txt)==4 and txt[3]in string.hexdigits:return int(txt[2:],16)
		return int(txt[2:],16)
	elif c.isdigit():
		if c=='0'and len(txt)==2:return 0
		for i in 3,2,1:
			if len(txt)>i and txt[1:1+i].isdigit():
				return(1+i,int(txt[1:1+i],8))
	else:
		try:return chr_esc[c]
		except KeyError:raise PreprocError("could not parse char literal '%s'"%txt) 
開發者ID:MOSAIC-UA,項目名稱:802.11ah-ns3,代碼行數:18,代碼來源:c_preproc.py

示例14: test_disable_caching

# 需要導入模塊: import string [as 別名]
# 或者: from string import hexdigits [as 別名]
def test_disable_caching(catalog_cache):
    conf['cache_disabled'] = True

    cat = catalog_cache['test_cache']
    cache = cat.cache[0]

    cache_paths = cache.load(cat._urlpath, output=False)
    cache_path = cache_paths[-1]

    assert cache_path == cat._urlpath

    conf['cache_disabled'] = False

    cache_paths = cache.load(cat._urlpath, output=False)
    cache_path = cache_paths[-1]

    assert cache._cache_dir in cache_path
    assert os.path.isfile(cache_path)

    cache_id = os.path.basename(os.path.dirname(cache_path))
    # Checking for md5 hash
    assert all(c in string.hexdigits for c in cache_id)
    cache.clear_all() 
開發者ID:intake,項目名稱:intake,代碼行數:25,代碼來源:test_caching_integration.py

示例15: test_ds_set_cache_dir

# 需要導入模塊: import string [as 別名]
# 或者: from string import hexdigits [as 別名]
def test_ds_set_cache_dir(catalog_cache):
    cat = catalog_cache['test_cache']()
    defaults = cat.cache_dirs

    new_cache_dir = os.path.join(os.getcwd(), 'test_cache_dir')
    cat.set_cache_dir(new_cache_dir)

    cache = cat.cache[0]
    assert make_path_posix(cache._cache_dir) == make_path_posix(new_cache_dir)

    cache_paths = cache.load(cat._urlpath, output=False)
    cache_path = cache_paths[-1]
    expected_cache_dir = make_path_posix(new_cache_dir)

    assert expected_cache_dir in cache_path
    assert defaults[0] not in cache_path
    assert os.path.isfile(cache_path)

    cache_id = os.path.basename(os.path.dirname(cache_path))
    # Checking for md5 hash
    assert all(c in string.hexdigits for c in cache_id)
    cache.clear_all()

    shutil.rmtree(expected_cache_dir) 
開發者ID:intake,項目名稱:intake,代碼行數:26,代碼來源:test_caching_integration.py


注:本文中的string.hexdigits方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。