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


Python base64.b64decode方法代碼示例

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


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

示例1: get_tray_icon

# 需要導入模塊: import base64 [as 別名]
# 或者: from base64 import b64decode [as 別名]
def get_tray_icon(self):
        base64_data = '''iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABHN
                         CSVQICAgIfAhkiAAAAQNJREFUOI3t1M9KAlEcxfHPmP0xU6Ogo
                         G0teoCiHjAIfIOIepvKRUE9R0G0KNApfy0c8hqKKUMrD9zVGc4
                         9nPtlsgp5n6qSVSk7cBG8CJ6sEX63UEcXz4jE20YNPbygPy25Q
                         o6oE+fEPXFF7A5yA9Eg2sQDcU3sJd6k89O4iiMcYKVol3rH2Mc
                         a1meZ4hMdNPCIj+SjHHfFZU94/0Nwlv4rWoY7vhrdeLNoO86bG
                         lym/ge3lsHDdI2fojbBG6sUtzOiQ1wQOwk6GwWKHeJyHtxOcFi
                         0TpFaxmnhNcyIW45bQ6RS3Hq4MeB7Ltyahki9Gd2xidWiwG9va
                         nCZqi7xlZGVHfwN6+5nU/ccBUYAAAAASUVORK5CYII='''

        pm = Qg.QPixmap()
        pm.loadFromData(base64.b64decode(base64_data))
        i = Qg.QIcon()
        i.addPixmap(pm)
        return i

    # OFF BY DEFAULT
    # 0.2 SEC DELAY TO LET USER FINISH TYPING BEFORE INPUT BECOMES A DB QUERY 
開發者ID:DoTheEvo,項目名稱:ANGRYsearch,代碼行數:21,代碼來源:angrysearch.py

示例2: __init__

# 需要導入模塊: import base64 [as 別名]
# 或者: from base64 import b64decode [as 別名]
def __init__(self, blob):
        super(Blob, self).__init__(blob)
        self._api = blob.get('url', '')

        #: Raw content of the blob.
        self.content = blob.get('content').encode()

        #: Encoding of the raw content.
        self.encoding = blob.get('encoding')

        #: Decoded content of the blob.
        self.decoded = self.content
        if self.encoding == 'base64':
            self.decoded = b64decode(self.content)

        #: Size of the blob in bytes
        self.size = blob.get('size')
        #: SHA1 of the blob
        self.sha = blob.get('sha') 
開發者ID:kislyuk,項目名稱:aegea,代碼行數:21,代碼來源:git.py

示例3: deserialize_ndarray

# 需要導入模塊: import base64 [as 別名]
# 或者: from base64 import b64decode [as 別名]
def deserialize_ndarray(d):
    """
    Deserializes a JSONified :obj:`numpy.ndarray`. Can handle arrays serialized
    using any of the methods in this module: :obj:`"npy"`, :obj:`"b64"`,
    :obj:`"readable"`.

    Args:
        d (`dict`): A dictionary representation of an :obj:`ndarray` object.

    Returns:
        An :obj:`ndarray` object.
    """
    if 'data' in d:
        x = np.fromstring(
            base64.b64decode(d['data']),
            dtype=d['dtype'])
        x.shape = d['shape']
        return x
    elif 'value' in d:
        return np.array(d['value'], dtype=d['dtype'])
    elif 'npy' in d:
        return deserialize_ndarray_npy(d)
    else:
        raise ValueError('Malformed np.ndarray encoding.') 
開發者ID:gregreen,項目名稱:dustmaps,代碼行數:26,代碼來源:json_serializers.py

示例4: lan_event

# 需要導入模塊: import base64 [as 別名]
# 或者: from base64 import b64decode [as 別名]
def lan_event(self):
        '''變更語言的方法'''
        #讀取本地配置文件
        num = 0
        with open(".\data.ini",'rb') as f:
            self.lan_data = f.readlines()
        with open(".\data.ini",'wb') as f:
            for line in self.lan_data:
                if num == self.dual_host_view.currentRow() + 1:
                    data = base64.b64decode(line)
                    data = json.loads(data.decode())
                    data['lan'] = self.lan_input.currentIndex()
                    f.write(base64.b64encode(json.dumps(data).encode()))
                    f.write('\n'.encode())
                else:
                    f.write(line)
                num += 1

        a = QMessageBox()
        #寫入成功提示
        a.information(a,self.tr("Success"),self.tr("Language will be changed after resrart the application")) 
開發者ID:Pryriat,項目名稱:BandwagongVPS_controller,代碼行數:23,代碼來源:bwh_ctr.py

示例5: getColoredPathway

# 需要導入模塊: import base64 [as 別名]
# 或者: from base64 import b64decode [as 別名]
def getColoredPathway(self, pathwayId, filetype="svg", revision=0,
            color=None, graphId=None):
        """Get a colored image version of the pathway.

        :param str pwId: The pathway identifier.
        :param int revision: The revision number of the pathway (use '0' for most recent version).
        :param str fileType:  The image type (One of 'svg', 'pdf' or 'png'). Not
            yet implemented. svg is returned for now.
        :returns: Binary form of the image.

        .. todo:: graphId, color parameters
        """

        url = self.url + "getColoredPathway?pwId={}".format(pathwayId)
        if revision:
            url += "&revision={}".format(revision)
        url += "&format=json"
        request = self.http_get(url)
        try:
            data = request['data']  
            return base64.b64decode(data)
        except:
            return request 
開發者ID:cokelaer,項目名稱:bioservices,代碼行數:25,代碼來源:wikipathway.py

示例6: image

# 需要導入模塊: import base64 [as 別名]
# 或者: from base64 import b64decode [as 別名]
def image(self, Id):
        """ Return string containing PNG binary image data of 2D structure image

        ::

            >>> from bioservices import *
            >>> s = ChemSpider()
            >>> ret = s.image(1020)
            >>> with open("test.png", "w") as f:
            ...     f.write(ret)
            >>> s.on_web("test.png")
        """
        url = "Search.asmx/GetCompoundThumbnail?id=%s&token=%s" % (Id, self._token)
        res = self.http_get(url, frmt="xml")
        res = self.easyXML(res)
        #TODO python3 compatible !
        import base64
        image = base64.b64decode(res.root.text)
        return image 
開發者ID:cokelaer,項目名稱:bioservices,代碼行數:21,代碼來源:chemspider.py

示例7: get_username_password

# 需要導入模塊: import base64 [as 別名]
# 或者: from base64 import b64decode [as 別名]
def get_username_password(userpass):
    """
    Please note: username and password can either be presented in plain text
    such as "admin:password" or base64 encoded such as "YWRtaW46cGFzc3dvcmQ=".
    Both forms should be returned from this function.
    """
    plaintext = base64.b64decode(userpass)

    segments = plaintext.split(':')
    count = len(segments)
    if count == 1:
        return segments[0], ''
    elif count == 2:
        return segments
    else:
        raise Exception('There should be at most two segments!') 
開發者ID:ParadropLabs,項目名稱:Paradrop,代碼行數:18,代碼來源:auth.py

示例8: load

# 需要導入模塊: import base64 [as 別名]
# 或者: from base64 import b64decode [as 別名]
def load(data, encoding="utf8"):
    """ Loads a base64 encoded schematic `str` object, 
    or a non-base65 encoded `bytes` object; returns a 
    Schematics object containing a Schematic, and it's 
    metadata, like width, height and tags."""
    if isinstance(data, str):
        base64header = "bXNjaAB"
        if not data.startswith(base64header):
            raise ValueError(f"String should start with: {base64header}")
        data = bytes(data, encoding)
        data = b64decode(data)

    if isinstance(data, bytes):
        data = msch.parse(data)
        return data
    else:
        raise ValueError(f"Unknown or unsupported type: {type(data)}")

########################################
## Writer
######################################## 
開發者ID:SimonWoodburyForget,項目名稱:mindustry-modding,代碼行數:23,代碼來源:msch.py

示例9: load_pem_data

# 需要導入模塊: import base64 [as 別名]
# 或者: from base64 import b64decode [as 別名]
def load_pem_data(filename, specifier):
	"""Loads the PEM payload, designated with a BEGIN and END specifier, from a
	file given by its filename."""
	data = None
	with open(filename, "r") as f:
		spec_begin = "-----BEGIN " + specifier + "-----"
		spec_end = "-----END " + specifier + "-----"
		for line in f:
			line = line.rstrip()
			if (data is None) and (line == spec_begin):
				data = [ ]
			elif (data is not None) and (line == spec_end):
				break
			elif data is not None:
				data.append(line)
	if data is None:
		raise Exception("Trying to parse PEM file with specifier '%s', but no such block in file found." % (specifier))
	data = base64.b64decode("".join(data).encode("utf-8"))
	return data 
開發者ID:johndoe31415,項目名稱:joeecc,代碼行數:21,代碼來源:Tools.py

示例10: decrypt_ecb

# 需要導入模塊: import base64 [as 別名]
# 或者: from base64 import b64decode [as 別名]
def decrypt_ecb(cipher_text, key):
    """
    SM4(ECB)解密
    :param cipher_text: 密文
    :param key: 密鑰, 小於等於16字節
    """
    cipher_text = b64decode(cipher_text)
    cipher_hex = _hex(cipher_text)

    # 密碼檢驗
    key = _key_iv_check(key_iv=key)
    plain_hex_list = []
    for i in _range(len(cipher_text) // BLOCK_BYTE):
        sub_hex = cipher_hex[i * BLOCK_HEX:(i + 1) * BLOCK_HEX]
        plain = decrypt(cipher_num=int(sub_hex, 16),
                        mk=int(_hex(key), 16))
        plain_hex_list.append(num2hex(num=plain, width=BLOCK_HEX))

    plain_text = _padding(_unhex(''.join(plain_hex_list)),
                          mode=SM4_DECRYPT)
    return plain_text if PY2 else plain_text.decode(E_FMT)


# 密碼塊鏈接(CBC) 
開發者ID:yang3yen,項目名稱:pysm4,代碼行數:26,代碼來源:sm4.py

示例11: decode_jwt

# 需要導入模塊: import base64 [as 別名]
# 或者: from base64 import b64decode [as 別名]
def decode_jwt(jwt_value):
    """
    :type jwt_value: str
    """
    try:
        headers_enc, payload_enc, verify_signature = jwt_value.split(".")
    except ValueError:
        raise jwt.InvalidTokenError()

    payload_enc += '=' * (-len(payload_enc) % 4)  # add padding
    payload = json.loads(base64.b64decode(payload_enc).decode("utf-8"))

    algorithms = getattr(settings, 'JWT_JWS_ALGORITHMS', ['HS256', 'RS256'])
    public_key_name = 'JWT_PUBLIC_KEY_{}'.format(payload['iss'].upper())
    public_key = getattr(settings, public_key_name, None)
    if not public_key:
        raise ImproperlyConfigured('Missing setting {}'.format(
                                   public_key_name))

    decoded = jwt.decode(jwt_value, public_key, algorithms=algorithms)
    return decoded 
開發者ID:Humanitec,項目名稱:django-oauth-toolkit-jwt,代碼行數:23,代碼來源:utils.py

示例12: retrieve_zip

# 需要導入模塊: import base64 [as 別名]
# 或者: from base64 import b64decode [as 別名]
def retrieve_zip(self, async_process_id):
        """ Retrieves ZIP file """
        result = self._retrieve_retrieve_result(async_process_id, 'true')
        state = result.find('mt:status', self._XML_NAMESPACES).text
        error_message = result.find('mt:errorMessage', self._XML_NAMESPACES)
        if error_message is not None:
            error_message = error_message.text

        # Check if there are any messages
        messages = []
        message_list = result.findall('mt:details/mt:messages', self._XML_NAMESPACES)
        for message in message_list:
            messages.append({
                'file': message.find('mt:fileName', self._XML_NAMESPACES).text,
                'message': message.find('mt:problem', self._XML_NAMESPACES).text
            })

        # Retrieve base64 encoded ZIP file
        zipfile_base64 = result.find('mt:zipFile', self._XML_NAMESPACES).text
        zipfile = b64decode(zipfile_base64)

        return state, error_message, messages, zipfile 
開發者ID:rbauction,項目名稱:sfdclib,代碼行數:24,代碼來源:metadata.py

示例13: decode

# 需要導入模塊: import base64 [as 別名]
# 或者: from base64 import b64decode [as 別名]
def decode(self, data64):
        data = b64decode(data64)
        inp = self.SECItem(0, data, len(data))
        out = self.SECItem(0, None, 0)

        e = self._PK11SDR_Decrypt(inp, out, None)
        LOG.debug("Decryption of data returned %s", e)
        try:
            if e == -1:
                LOG.error("Password decryption failed. Passwords protected by a Master Password!")
                self.handle_error()
                raise Exit(Exit.NEED_MASTER_PASSWORD)

            res = ct.string_at(out.data, out.len).decode(LIB_ENCODING)
        finally:
            # Avoid leaking SECItem
            self._SECITEM_ZfreeItem(out, 0)

        return res 
開發者ID:unode,項目名稱:firefox_decrypt,代碼行數:21,代碼來源:firefox_decrypt.py

示例14: getenv

# 需要導入模塊: import base64 [as 別名]
# 或者: from base64 import b64decode [as 別名]
def getenv(name: str, fallback: str = "") -> str:
    """Return an (optionally base64-encoded) env var."""
    variable = environ.get(name)
    if DEPLOY and variable is not None:
        variable = base64.b64decode(variable).decode()
    return variable or fallback 
開發者ID:CyberDiscovery,項目名稱:cyberdisc-bot,代碼行數:8,代碼來源:constants.py

示例15: eval_base64_decode

# 需要導入模塊: import base64 [as 別名]
# 或者: from base64 import b64decode [as 別名]
def eval_base64_decode(self, data, ctx=None):
        """Decode data from base64.

        Light weight wrapper around base64 library to shed the ctx kwarg

        :param data: data to be decoded
        :param ctx: throwaway, just allows a generic interface for pipeline segments
        """
        return base64.b64decode(data) 
開發者ID:airshipit,項目名稱:drydock,代碼行數:11,代碼來源:bootaction.py


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