本文整理汇总了Python中string.hexdigits方法的典型用法代码示例。如果您正苦于以下问题:Python string.hexdigits方法的具体用法?Python string.hexdigits怎么用?Python string.hexdigits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块string的用法示例。

在下文中一共展示了string.hexdigits方法的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: api_config

​点赞 6

# 需要导入模块: 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,

示例2: s_hexlit

​点赞 6

# 需要导入模块: 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,

示例3: s_hexlit

​点赞 6

# 需要导入模块: 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,

示例4: post

​点赞 6

# 需要导入模块: 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,

示例5: delete

​点赞 6

# 需要导入模块: 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,

示例6: isHex

​点赞 6

# 需要导入模块: 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,

示例7: check_wildcard

​点赞 6

# 需要导入模块: 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,

示例8: __init__

​点赞 6

# 需要导入模块: 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,

示例9: callback

​点赞 6

# 需要导入模块: 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,

示例10: step_size_start

​点赞 6

# 需要导入模块: 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,

示例11: step_size

​点赞 6

# 需要导入模块: 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,

示例12: OnChar

​点赞 6

# 需要导入模块: 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,

示例13: parse_char

​点赞 6

# 需要导入模块: 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,

示例14: test_disable_caching

​点赞 6

# 需要导入模块: 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,

示例15: test_ds_set_cache_dir

​点赞 6

# 需要导入模块: 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,

示例16: set_tg_api

​点赞 5

# 需要导入模块: import string [as 别名]

# 或者: from string import hexdigits [as 别名]

def set_tg_api(self, request):

if self.client_data and await self.check_user(request) is None:

return web.Response(status=302, headers={"Location": "/"}) # They gotta sign in.

text = await request.text()

if len(text) < 36:

return web.Response(status=400)

api_id = text[32:]

api_hash = text[:32]

if any(c not in string.hexdigits for c in api_hash) or any(c not in string.digits for c in api_id):

return web.Response(status=400)

with open(os.path.join(utils.get_base_dir(), "api_token.py"), "w") as f:

f.write("HASH = \"" + api_hash + "\"\nID = \"" + api_id + "\"\n")

self.api_token = collections.namedtuple("api_token", ("ID", "HASH"))(api_id, api_hash)

self.api_set.set()

return web.Response()

开发者ID:friendly-telegram,项目名称:friendly-telegram,代码行数:17,

示例17: isHexString

​点赞 5

# 需要导入模块: import string [as 别名]

# 或者: from string import hexdigits [as 别名]

def isHexString(data):

"""

Test if a string contains only hex digits.

"""

return all(c in string.hexdigits for c in data)

开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:7,

示例18: is_single_address

​点赞 5

# 需要导入模块: import string [as 别名]

# 或者: from string import hexdigits [as 别名]

def is_single_address(self):

return all([

all(c in string.hexdigits for c in self.domain),

all(c in string.hexdigits for c in self.bus),

all(c in string.hexdigits for c in self.slot),

all(c in string.hexdigits for c in self.func)])

开发者ID:openstack,项目名称:zun,代码行数:8,

示例19: _mock

​点赞 5

# 需要导入模块: import string [as 别名]

# 或者: from string import hexdigits [as 别名]

def _mock(self, context=None):

return random_string(self.LENGTH, string.hexdigits)

开发者ID:remg427,项目名称:misp42splunk,代码行数:4,

示例20: validHex

​点赞 5

# 需要导入模块: import string [as 别名]

# 或者: from string import hexdigits [as 别名]

def validHex(cmd):

ishex = all(c in string.hexdigits for c in cmd)

if len(cmd) == 2 and ishex:

return cmd

else:

parser.error("Please issue a two-character hex command, e.g. 0A")

# Parse commandline arguments

开发者ID:softScheck,项目名称:tplink-smartplug,代码行数:10,

示例21: test_git_version

​点赞 5

# 需要导入模块: import string [as 别名]

# 或者: from string import hexdigits [as 别名]

def test_git_version():

# GH 21295

git_version = pd.__git_version__

assert len(git_version) == 40

assert all(c in string.hexdigits for c in git_version)

开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,

示例22: is_valid_hex

​点赞 5

# 需要导入模块: import string [as 别名]

# 或者: from string import hexdigits [as 别名]

def is_valid_hex(s):

"""Can only detect if something definitely is *not* hex (could still return true by

coincidence).

But in this case all asm op codes begin with "OP_" as per https://en.bitcoin.it/wiki/Script.

So all return False. The only exception to this is for OP_PUSHDATA codes 1 - 75."""

return all(c in string.hexdigits for c in s)

开发者ID:AustEcon,项目名称:bitsv,代码行数:8,

示例23: put

​点赞 5

# 需要导入模块: import string [as 别名]

# 或者: from string import hexdigits [as 别名]

def put(self, digest, container_id):

"""

Reset (delete and start) a running DockerContainer instance

"""

# 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 for char in container_id):

raise PicoException("Invalid container ID", 400)

if any(char not in string.hexdigits + "sha:" for char in digest):

raise PicoException("Invalid image digest", 400)

# Delete the container

del_result = api.docker.delete(container_id)

# Create the container

create_result = api.docker.create(tid, digest)

if del_result and create_result["success"]:

return jsonify({"success": True,

"message": "Challenge reset.\nBe sure to use the new port."})

else:

return jsonify({"success": False, "message": "Error resetting challenge"})

开发者ID:picoCTF,项目名称:picoCTF,代码行数:29,

示例24: qname_handler

​点赞 5

# 需要导入模块: import string [as 别名]

# 或者: from string import hexdigits [as 别名]

def qname_handler(qname):

subdomain = qname.split(".")[0]

if(all(c in string.hexdigits for c in subdomain) and len(subdomain) % 2 == 0):

data = unhexlify(subdomain)

print data.split(":")

开发者ID:GoSecure,项目名称:break-fast-serial,代码行数:8,

示例25: hexstr

​点赞 5

# 需要导入模块: import string [as 别名]

# 或者: from string import hexdigits [as 别名]

def hexstr(s):

import string

h = string.hexdigits

r = ''

for c in s:

i = ord(c)

r = r + h[(i >> 4) & 0xF] + h[i & 0xF]

return r

开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,

示例26: test_attrs

​点赞 5

# 需要导入模块: import string [as 别名]

# 或者: from string import hexdigits [as 别名]

def test_attrs(self):

string.whitespace

string.lowercase

string.uppercase

string.letters

string.digits

string.hexdigits

string.octdigits

string.punctuation

string.printable

开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,

示例27: test_hash_string_to_hex

​点赞 5

# 需要导入模块: import string [as 别名]

# 或者: from string import hexdigits [as 别名]

def test_hash_string_to_hex(self):

"""Test that the string hash function returns a hex string."""

result = self.hasher.hash_string_to_hex(self.string_to_hash)

self.assertIsInstance(result, str)

for char in result:

self.assertIn(char, string.hexdigits)

开发者ID:project-koku,项目名称:koku,代码行数:8,

示例28: random_file_extension

​点赞 5

# 需要导入模块: import string [as 别名]

# 或者: from string import hexdigits [as 别名]

def random_file_extension(num_digits=8):

return ''.join(random.choice(string.hexdigits) for _ in range(num_digits))

开发者ID:skarlekar,项目名称:faces,代码行数:4,

注:本文中的string.hexdigits方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。

python中string.digits_Python string.hexdigits方法代码示例相关推荐

  1. python中的scaler_Python preprocessing.MaxAbsScaler方法代码示例

    本文整理汇总了Python中sklearn.preprocessing.MaxAbsScaler方法的典型用法代码示例.如果您正苦于以下问题:Python preprocessing.MaxAbsSc ...

  2. python中np zeros_Python numpy.zeros方法代码示例

    本文整理汇总了Python中numpy.zeros方法的典型用法代码示例.如果您正苦于以下问题:Python numpy.zeros方法的具体用法?Python numpy.zeros怎么用?Pyth ...

  3. python geometry用法_Python geometry.MultiPolygon方法代码示例

    本文整理汇总了Python中shapely.geometry.MultiPolygon方法的典型用法代码示例.如果您正苦于以下问题:Python geometry.MultiPolygon方法的具体用 ...

  4. python管理工具ports_Python options.port方法代码示例

    本文整理汇总了Python中tornado.options.port方法的典型用法代码示例.如果您正苦于以下问题:Python options.port方法的具体用法?Python options.p ...

  5. python os path isfile_Python path.isfile方法代码示例

    本文整理汇总了Python中os.path.isfile方法的典型用法代码示例.如果您正苦于以下问题:Python path.isfile方法的具体用法?Python path.isfile怎么用?P ...

  6. python html模板_Python html.format_html方法代码示例

    本文整理汇总了Python中django.utils.html.format_html方法的典型用法代码示例.如果您正苦于以下问题:Python html.format_html方法的具体用法?Pyt ...

  7. python session模块_Python backend.set_session方法代码示例

    本文整理汇总了Python中keras.backend.set_session方法的典型用法代码示例.如果您正苦于以下问题:Python backend.set_session方法的具体用法?Pyth ...

  8. python get score gain_Python functional.linear方法代码示例

    本文整理汇总了Python中torch.nn.functional.linear方法的典型用法代码示例.如果您正苦于以下问题:Python functional.linear方法的具体用法?Pytho ...

  9. python color属性_Python turtle.color方法代码示例

    本文整理汇总了Python中turtle.color方法的典型用法代码示例.如果您正苦于以下问题:Python turtle.color方法的具体用法?Python turtle.color怎么用?P ...

最新文章

  1. Vue2.0 入门 安装Vue-cli
  2. CVPR 2020 《Context-Aware Group Captioning via Self-Attention and Contrastive Features》论文笔记(数据集)
  3. 京东五星电器送扫地机器人_家电也流行“套餐”,京东五星电器吹响国庆家装“集结号”...
  4. 一个写得很不错的vuex详解(转)
  5. 主流开源编解码器Xvid,x264,ffmpeg 性能对比
  6. leetcode 484. Find Permutation 思维题
  7. c语言编译如何去掉warning,16种C语言编译警告(Warning)类型的解决方法
  8. 以眼睛的名义:一些光度学概念的解析
  9. 初识ObjectBox--Android平台
  10. css 禁止录入中文
  11. wireless 时好时断的一些解决的建议
  12. IaaS基础架构云 —— 云网络
  13. 张宇1000题高等数学 第八章 一元函数积分学的概念与性质
  14. php怎么上传文档,php
  15. 复旦版最佳医院排行 沪21家医院入选全国百佳
  16. 十、cut ,sort,wc,unip,tee,tr,split 命令
  17. (阿里云笔记)购置域名+云解析DNS域名
  18. 【寒江雪】Go实现状态模式
  19. 解决Win 10桌面 IE 图标消失问题的注册表代码
  20. 陈莉君 linux内核,Linux内核分析与应用 西安邮电大学(陈莉君)

热门文章

  1. C++中的内存分配new()
  2. SAP FI配置步骤
  3. Node buffer
  4. vue 自定义组件使用v-model
  5. CodeForces 589J Cleaner Robot
  6. springMVC分析-1
  7. firefox os 2.0版模拟器QQ初体验
  8. 关注健康,从现在开始(视力篇)
  9. Unity3D面试问题
  10. 赣南师范学院数学竞赛培训第10套模拟试卷参考解答