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


Python rsa.VerificationError方法代碼示例

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


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

示例1: unpack_license_key

# 需要導入模塊: import rsa [as 別名]
# 或者: from rsa import VerificationError [as 別名]
def unpack_license_key(key_str, pubkey_args):
    """
    Decode a string of license key data produced by `pack_license_key`. In other
    words, this function is the inverse of `pack_...` above:

        data == unpack_license_key(pack_license_key(data, ...), ...)

    If the given string is not a valid key, `InvalidKey` is raised.

    The parameter `pubkey_args` is a dictionary containing values for the RSA
    fields "n" and "e". It can be generated with fbs's command `init_licensing`.
    """
    try:
        result = json.loads(key_str)
    except ValueError:
        raise InvalidKey() from None
    try:
        signature = result.pop('key')
    except KeyError:
        raise InvalidKey() from None
    try:
        signature_bytes = b64decode(signature.encode('ascii'))
    except ValueError:
        raise InvalidKey() from None
    try:
        rsa.verify(_dumpb(result), signature_bytes, PublicKey(**pubkey_args))
    except VerificationError:
        raise InvalidKey() from None
    return result 
開發者ID:mherrmann,項目名稱:fbs,代碼行數:31,代碼來源:licensing.py

示例2: _validate_signature

# 需要導入模塊: import rsa [as 別名]
# 或者: from rsa import VerificationError [as 別名]
def _validate_signature(self, receipt: str, signature: str) -> bool:
        try:
            sig = base64.standard_b64decode(signature)
            return rsa.verify(receipt.encode(), sig, self.public_key)
        except (rsa.VerificationError, TypeError, ValueError, BaseException):
            return False 
開發者ID:dotpot,項目名稱:InAppPy,代碼行數:8,代碼來源:googleplay.py

示例3: perform_operation

# 需要導入模塊: import rsa [as 別名]
# 或者: from rsa import VerificationError [as 別名]
def perform_operation(self, indata, pub_key, cli_args):
        """Verifies files."""

        signature_file = cli_args[1]

        with open(signature_file, 'rb') as sigfile:
            signature = sigfile.read()

        try:
            rsa.verify(indata, signature, pub_key)
        except rsa.VerificationError:
            raise SystemExit('Verification failed.')

        print('Verification OK', file=sys.stderr) 
開發者ID:Deltares,項目名稱:aqua-monitor,代碼行數:16,代碼來源:cli.py

示例4: perform_operation

# 需要導入模塊: import rsa [as 別名]
# 或者: from rsa import VerificationError [as 別名]
def perform_operation(self, indata, pub_key, cli_args):
        '''Decrypts files.'''

        signature_file = cli_args[1]
        
        with open(signature_file, 'rb') as sigfile:
            signature = sigfile.read()

        try:
            rsa.verify(indata, signature, pub_key)
        except rsa.VerificationError:
            raise SystemExit('Verification failed.')

        print('Verification OK', file=sys.stderr) 
開發者ID:deadblue,項目名稱:baidupan_shell,代碼行數:16,代碼來源:cli.py

示例5: _validate_signature

# 需要導入模塊: import rsa [as 別名]
# 或者: from rsa import VerificationError [as 別名]
def _validate_signature(self, receipt, signature):
        try:
            sig = base64.standard_b64decode(signature)
            return rsa.verify(receipt.encode(), sig, self.public_key)
        except (rsa.VerificationError, TypeError):
            return False 
開發者ID:keeprocking,項目名稱:pyinapp,代碼行數:8,代碼來源:googleplay.py


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