当前位置: 首页>>代码示例>>Python>>正文


Python base64.b85encode方法代码示例

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


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

示例1: crypter

# 需要导入模块: import base64 [as 别名]
# 或者: from base64 import b85encode [as 别名]
def crypter(ack='',iv='2769514380123456',base='b64'):
    ahk = hmac.new(b'vilame',ack.encode(),'md5').hexdigest()
    c = CrypterAES(ahk, iv)
    if base == 'b16': _encode,_decode = base64.b16encode,base64.b16decode
    if base == 'b32': _encode,_decode = base64.b32encode,base64.b32decode
    if base == 'b64': _encode,_decode = base64.b64encode,base64.b64decode
    if base == 'b85': _encode,_decode = base64.b85encode,base64.b85decode
    if base == 'urlsafe_b64': _encode,_decode = base64.urlsafe_b64encode,base64.urlsafe_b64decode
    def zbase_enc(data):
        return _encode(zlib.compress(data.encode())[2:-4]).decode()
    def zbase_dec(basedata):
        return zlib.decompress(_decode(basedata),-15).decode()
    def zencrypt(data): return c.encrypt_base(zlib.compress(data.encode())[2:-4],_encode)
    def zdecrypt(data): return zlib.decompress(c.decrypt_base(data,_decode),-15).decode()
    c.zencrypt = zencrypt
    c.zdecrypt = zdecrypt
    c.zbase_enc = zbase_enc
    c.zbase_dec = zbase_dec
    c.encrypt = lambda data:c.encrypt_base(data,_encode)
    c.decrypt = lambda data:c.decrypt_base(data,_decode).decode()
    return c 
开发者ID:cilame,项目名称:vrequest,代码行数:23,代码来源:pyzlibaes.py

示例2: send_decoding_error

# 需要导入模块: import base64 [as 别名]
# 或者: from base64 import b85encode [as 别名]
def send_decoding_error(self, envelope: Envelope) -> None:
        """
        Handle a decoding error.

        :param envelope: the envelope
        :return: None
        """
        self.context.logger.warning(
            "Decoding error for envelope: {}. Protocol_id='{}' and message='{!r}' are inconsistent.".format(
                envelope, envelope.protocol_id, envelope.message
            )
        )
        encoded_envelope = base64.b85encode(envelope.encode())
        reply = DefaultMessage(
            dialogue_reference=("", ""),
            message_id=1,
            target=0,
            performative=DefaultMessage.Performative.ERROR,
            error_code=DefaultMessage.ErrorCode.DECODING_ERROR,
            error_msg="Decoding error.",
            error_data={"envelope": encoded_envelope},
        )
        reply.counterparty = envelope.sender
        self.context.outbox.put_message(message=reply) 
开发者ID:fetchai,项目名称:agents-aea,代码行数:26,代码来源:handlers.py

示例3: test_encode_base85

# 需要导入模块: import base64 [as 别名]
# 或者: from base64 import b85encode [as 别名]
def test_encode_base85(self):
        if sys.version_info.major != 3 or \
                sys.version_info.minor < 4:
            self.fail('Base85 support not available for the current Python version!')
        data_bytes = self._random_bytes()
        encoded_bytes = base64.b85encode(data_bytes)
        plugin = self._plugins.get_plugin_instance('base85')
        result = plugin.process(data_bytes)
        self.assertIsNone(plugin.error), 'An error occurred during Base85 encoding'
        self.assertIsInstance(result, bytes,
            'Base85 encoding result should be bytes or bytearray, '
            'got %s instead' % type(result))
        self.assertEqual(encoded_bytes, result)
        data_str = self._random_str()
        self.assertRaises(TypeError, functools.partial(
            plugin.process, data_str), 'Unexpected exception raised') 
开发者ID:takeshixx,项目名称:deen,代码行数:18,代码来源:test_plugins.py

示例4: test_decode_base85

# 需要导入模块: import base64 [as 别名]
# 或者: from base64 import b85encode [as 别名]
def test_decode_base85(self):
        if sys.version_info.major != 3 or \
                sys.version_info.minor < 4:
            self.fail('Base85 support not available for the current Python version!')
        data_bytes = self._random_bytes()
        encoded_bytes = base64.b85encode(data_bytes)
        plugin = self._plugins.get_plugin_instance('base85')
        result = plugin.unprocess(encoded_bytes)
        self.assertIsNone(plugin.error), 'An error occurred during Base85 decoding'
        self.assertIsInstance(result, bytes,
            'Base85 decoding result should be bytes or bytearray, '
            'got %s instead' % type(result))
        self.assertEqual(data_bytes, result)
        data_str = self._random_str()
        self.assertRaises(TypeError, functools.partial(
            plugin.unprocess, data_str), 'Unexpected exception raised') 
开发者ID:takeshixx,项目名称:deen,代码行数:18,代码来源:test_plugins.py

示例5: encode

# 需要导入模块: import base64 [as 别名]
# 或者: from base64 import b85encode [as 别名]
def encode(self, text):
		return base64.b85encode(text).replace("=","") 
开发者ID:earthquake,项目名称:XFLTReaT,代码行数:4,代码来源:encoding.py

示例6: _pickle_object

# 需要导入模块: import base64 [as 别名]
# 或者: from base64 import b85encode [as 别名]
def _pickle_object(x: typing.Any) -> str:
    pck: str = base64.b85encode(gzip.compress(pickle.dumps(x, protocol=4))).decode().strip()
    segment_gen = map(''.join, itertools.zip_longest(*([iter(pck)] * 100), fillvalue=''))
    return '\n'.join(repr(x) for x in segment_gen) 
开发者ID:UAVCAN,项目名称:pyuavcan,代码行数:6,代码来源:_compiler.py

示例7: packTree

# 需要导入模块: import base64 [as 别名]
# 或者: from base64 import b85encode [as 别名]
def packTree(src):
    if not os.path.isdir(src):
        raise BuildError("Cannot import '{}': not a directory!".format(src))

    try:
        f = io.BytesIO()
        with tarfile.open(fileobj=f, mode="w:xz") as tar:
            tar.add(src, arcname=".")
    except OSError as e:
        raise BuildError("Error gathering files: {}".format(str(e)))
    return base64.b85encode(f.getvalue()).decode('ascii') 
开发者ID:BobBuildTool,项目名称:bob,代码行数:13,代码来源:imp.py

示例8: random_string

# 需要导入模块: import base64 [as 别名]
# 或者: from base64 import b85encode [as 别名]
def random_string(length=TRACKER_PASSWORD_LENGTH_MIN):
    salt = b85encode(urandom(length))
    return salt.decode() 
开发者ID:archlinux,项目名称:arch-security-tracker,代码行数:5,代码来源:user.py

示例9: hash_password

# 需要导入模块: import base64 [as 别名]
# 或者: from base64 import b85encode [as 别名]
def hash_password(password, salt):
    hashed = b85encode(shash(password, salt[:User.SALT_LENGTH]))
    return hashed.decode()[:User.PASSWORD_LENGTH] 
开发者ID:archlinux,项目名称:arch-security-tracker,代码行数:5,代码来源:user.py

示例10: main

# 需要导入模块: import base64 [as 别名]
# 或者: from base64 import b85encode [as 别名]
def main():
    with open(INPUT_FILE, 'rb') as fd:
        contents = fd.read()

    encoded_contents = base64.b85encode(gzip.compress(contents)).decode()

    print("ENCODED_LIB_CONTENTS = (")
    for line in textwrap.wrap(encoded_contents, 128):
        print("    '%s'" % line)
    print(")") 
开发者ID:dimaryaz,项目名称:dropbox_ext4,代码行数:12,代码来源:encode_lib.py

示例11: test_b85encode

# 需要导入模块: import base64 [as 别名]
# 或者: from base64 import b85encode [as 别名]
def test_b85encode(self):
        eq = self.assertEqual

        tests = {
            b'': b'',
            b'www.python.org': b'cXxL#aCvlSZ*DGca%T',
            bytes(range(255)): b"""009C61O)~M2nh-c3=Iws5D^j+6crX17#SKH9337X"""
                b"""AR!_nBqb&%C@Cr{EG;fCFflSSG&MFiI5|2yJUu=?KtV!7L`6nNNJ&ad"""
                b"""OifNtP*GA-R8>}2SXo+ITwPvYU}0ioWMyV&XlZI|Y;A6DaB*^Tbai%j"""
                b"""czJqze0_d@fPsR8goTEOh>41ejE#<ukdcy;l$Dm3n3<ZJoSmMZprN9p"""
                b"""q@|{(sHv)}tgWuEu(7hUw6(UkxVgH!yuH4^z`?@9#Kp$P$jQpf%+1cv"""
                b"""(9zP<)YaD4*xB0K+}+;a;Njxq<mKk)=;`X~?CtLF@bU8V^!4`l`1$(#"""
                b"""{Qdp""",
            b"""abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"""
                b"""0123456789!@#0^&*();:<>,. []{}""":
                b"""VPa!sWoBn+X=-b1ZEkOHadLBXb#`}nd3r%YLqtVJM@UIZOH55pPf$@("""
                b"""Q&d$}S6EqEFflSSG&MFiI5{CeBQRbjDkv#CIy^osE+AW7dwl""",
            b'no padding..': b'Zf_uPVPs@!Zf7no',
            b'zero compression\x00\x00\x00\x00': b'dS!BNAY*TBaB^jHb7^mG00000',
            b'zero compression\x00\x00\x00': b'dS!BNAY*TBaB^jHb7^mG0000',
            b"""Boundary:\x00\x00\x00\x00""": b"""LT`0$WMOi7IsgCw00""",
            b'Space compr:    ': b'Q*dEpWgug3ZE$irARr(h',
            b'\xff': b'{{',
            b'\xff'*2: b'|Nj',
            b'\xff'*3: b'|Ns9',
            b'\xff'*4: b'|NsC0',
        }

        for data, res in tests.items():
            eq(base64.b85encode(data), res)

        self.check_other_types(base64.b85encode, b"www.python.org",
                               b'cXxL#aCvlSZ*DGca%T') 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:35,代码来源:test_base64.py

示例12: test_b85_padding

# 需要导入模块: import base64 [as 别名]
# 或者: from base64 import b85encode [as 别名]
def test_b85_padding(self):
        eq = self.assertEqual

        eq(base64.b85encode(b"x", pad=True), b'cmMzZ')
        eq(base64.b85encode(b"xx", pad=True), b'cz6H+')
        eq(base64.b85encode(b"xxx", pad=True), b'czAdK')
        eq(base64.b85encode(b"xxxx", pad=True), b'czAet')
        eq(base64.b85encode(b"xxxxx", pad=True), b'czAetcmMzZ')

        eq(base64.b85decode(b'cmMzZ'), b"x\x00\x00\x00")
        eq(base64.b85decode(b'cz6H+'), b"xx\x00\x00")
        eq(base64.b85decode(b'czAdK'), b"xxx\x00")
        eq(base64.b85decode(b'czAet'), b"xxxx")
        eq(base64.b85decode(b'czAetcmMzZ'), b"xxxxx\x00\x00\x00") 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:16,代码来源:test_base64.py

示例13: dump_observation

# 需要导入模块: import base64 [as 别名]
# 或者: from base64 import b85encode [as 别名]
def dump_observation(observation, f):
    if 'cache' in observation:
        observation['cache'] = \
            str(base64.b85encode(pickle.dumps(observation['cache'])), 'ascii')

    json.dump(observation, f)
    f.write("\n") 
开发者ID:wikimedia,项目名称:revscoring,代码行数:9,代码来源:util.py

示例14: send_unsupported_protocol

# 需要导入模块: import base64 [as 别名]
# 或者: from base64 import b85encode [as 别名]
def send_unsupported_protocol(self, envelope: Envelope) -> None:
        """
        Handle the received envelope in case the protocol is not supported.

        :param envelope: the envelope
        :return: None
        """
        self.context.logger.warning(
            "Unsupported protocol: {}. You might want to add a handler for this protocol.".format(
                envelope.protocol_id
            )
        )
        encoded_protocol_id = base64.b85encode(str.encode(str(envelope.protocol_id)))
        encoded_envelope = base64.b85encode(envelope.encode())
        reply = DefaultMessage(
            dialogue_reference=("", ""),
            message_id=1,
            target=0,
            performative=DefaultMessage.Performative.ERROR,
            error_code=DefaultMessage.ErrorCode.UNSUPPORTED_PROTOCOL,
            error_msg="Unsupported protocol.",
            error_data={
                "protocol_id": encoded_protocol_id,
                "envelope": encoded_envelope,
            },
        )
        reply.counterparty = envelope.sender
        self.context.outbox.put_message(message=reply) 
开发者ID:fetchai,项目名称:agents-aea,代码行数:30,代码来源:handlers.py

示例15: send_unsupported_skill

# 需要导入模块: import base64 [as 别名]
# 或者: from base64 import b85encode [as 别名]
def send_unsupported_skill(self, envelope: Envelope) -> None:
        """
        Handle the received envelope in case the skill is not supported.

        :param envelope: the envelope
        :return: None
        """
        if envelope.skill_id is None:
            self.context.logger.warning(
                "Cannot handle envelope: no active handler registered for the protocol_id='{}'.".format(
                    envelope.protocol_id
                )
            )
        else:
            self.context.logger.warning(
                "Cannot handle envelope: no active handler registered for the protocol_id='{}' and skill_id='{}'.".format(
                    envelope.protocol_id, envelope.skill_id
                )
            )
        encoded_envelope = base64.b85encode(envelope.encode())
        reply = DefaultMessage(
            dialogue_reference=("", ""),
            message_id=1,
            target=0,
            performative=DefaultMessage.Performative.ERROR,
            error_code=DefaultMessage.ErrorCode.UNSUPPORTED_SKILL,
            error_msg="Unsupported skill.",
            error_data={"envelope": encoded_envelope},
        )
        reply.counterparty = envelope.sender
        self.context.outbox.put_message(message=reply) 
开发者ID:fetchai,项目名称:agents-aea,代码行数:33,代码来源:handlers.py


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