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


Python rsa.verify方法代碼示例

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


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

示例1: verify

# 需要導入模塊: import rsa [as 別名]
# 或者: from rsa import verify [as 別名]
def verify(self, purchase_token: str, product_sku: str, is_subscription: bool = False) -> dict:
        service = build("androidpublisher", "v3", http=self.http)

        if is_subscription:
            result = self.check_purchase_subscription(purchase_token, product_sku, service)
            cancel_reason = int(result.get("cancelReason", 0))

            if cancel_reason != 0:
                raise GoogleError("Subscription is canceled", result)

            ms_timestamp = result.get("expiryTimeMillis", 0)

            if self._ms_timestamp_expired(ms_timestamp):
                raise GoogleError("Subscription expired", result)
        else:
            result = self.check_purchase_product(purchase_token, product_sku, service)
            purchase_state = int(result.get("purchaseState", 1))

            if purchase_state != 0:
                raise GoogleError("Purchase cancelled", result)

        return result 
開發者ID:dotpot,項目名稱:InAppPy,代碼行數:24,代碼來源:googleplay.py

示例2: verify_ali_data

# 需要導入模塊: import rsa [as 別名]
# 或者: from rsa import verify [as 別名]
def verify_ali_data(valueDict):
    logger.info('verifying data from ali')
    sign = valueDict['sign']
    # remove sign and sign_type
    del valueDict['sign']
    if 'sign_type' in valueDict:
        del valueDict['sign_type']
    # contact string need to verify
    temp = []
    for key in sorted(valueDict):
        if not valueDict[key]:
            continue
        temp.append('{}={}'.format(key, valueDict[key]))
    tempStr = '&'.join(temp)
    logger.info('string to verify:{}'.format(tempStr))
    return verify(tempStr, sign, settings.ALIPAY['ali_public_key_pem']) 
開發者ID:panweifeng,項目名稱:openunipay,代碼行數:18,代碼來源:security.py

示例3: verify

# 需要導入模塊: import rsa [as 別名]
# 或者: from rsa import verify [as 別名]
def verify(self, message, signature, hash_method=None):
        """

        :param message:
        :param signature:
        :param hash_method:
        :return:
        """
        try:
            compare_hash_method = hash_method or self.hash_method
            hash_m = rsa.verify(message.encode(), signature, self.public_key)
            if hash_m == compare_hash_method:
                return True
            else:
                return False
        except:
            return False 
開發者ID:seecode-audit,項目名稱:seecode-scanner,代碼行數:19,代碼來源:rsaencrypt.py

示例4: valid_token

# 需要導入模塊: import rsa [as 別名]
# 或者: from rsa import verify [as 別名]
def valid_token():
    resp = requests.get(url = "http://zlclclc.cn/get_token")
    s = eval(resp.json()["signature"])
    signature = base64.decodestring(s)

    crypto = resp.json()["token_message"]
    message = crypto[2:-6]+'\n'

    with open('/home/mmmsc/listen-now/project/Helper/pubkey.pem','r') as f:
        pubkey = rsa.PublicKey.load_pkcs1(f.read().encode())        
    
    v = rsa.verify(message.encode(), signature, pubkey)     
    
    try:
        rsa.verify(message.encode(), signature, pubkey)
        sign_valid = 1
    except:

        sign_valid = 0
    #token = crypto[:110]+'\n'+crypto[112:115]
    token_message = crypto[2:110]+r'\n'+crypto[112:115]      
    parameter = {"sign_valid":sign_valid,"token":token_message}
    valid_key = requests.post(url = "http://zlclclc.cn/exist_token",data = json.dumps(parameter))
    return token_message
#print(valid_token()) 
開發者ID:listen-now,項目名稱:listen-now,代碼行數:27,代碼來源:valid_token.py

示例5: checkSign

# 需要導入模塊: import rsa [as 別名]
# 或者: from rsa import verify [as 別名]
def checkSign(self, mess, result, pubkey=None):
        """
        驗證簽名:傳入解密後明文、簽名、公鑰,驗證成功返回哈希方法,失敗則報錯
        :param mess: str
        :param result: bytes
        :param pubkey: 
        :return: str
        """
        if None == pubkey:
            pubkey = self.privkey
        try:
            result = rsa.verify(mess, result, pubkey)
            return result
        except:
            return False 
開發者ID:inlike,項目名稱:R-A-M-D-D3-S-M-H,代碼行數:17,代碼來源:RSA-AES-MD5-DES-DES3-MD5-SHA-HMAC.py

示例6: verifySRCTokenUtxoPayload

# 需要導入模塊: import rsa [as 別名]
# 或者: from rsa import verify [as 別名]
def verifySRCTokenUtxoPayload(self, payload, signature):
		try:
			return rsa.verify(payload, signature.decode('hex'), addr_to_pubkey(self.addr))
		except:
			return False 
開發者ID:sixstars,項目名稱:starctf2018,代碼行數:7,代碼來源:serve.py

示例7: verify_utxo_signature

# 需要導入模塊: import rsa [as 別名]
# 或者: from rsa import verify [as 別名]
def verify_utxo_signature(address, utxo_id, signature):
	try:
		return rsa.verify(utxo_id, signature.decode('hex'), addr_to_pubkey(address))
	except:
		return False 
開發者ID:sixstars,項目名稱:starctf2018,代碼行數:7,代碼來源:serve.py

示例8: unpack_license_key

# 需要導入模塊: import rsa [as 別名]
# 或者: from rsa import verify [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

示例9: _validate_signature

# 需要導入模塊: import rsa [as 別名]
# 或者: from rsa import verify [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

示例10: verify_with_result

# 需要導入模塊: import rsa [as 別名]
# 或者: from rsa import verify [as 別名]
def verify_with_result(
        self, purchase_token: str, product_sku: str, is_subscription: bool = False
    ) -> GoogleVerificationResult:
        """Verifies by returning verification result instead of raising an error,
        basically it's and better alternative to verify method."""
        service = build("androidpublisher", "v3", http=self.http)
        verification_result = GoogleVerificationResult({}, False, False)

        if is_subscription:
            result = self.check_purchase_subscription(purchase_token, product_sku, service)
            verification_result.raw_response = result

            cancel_reason = int(result.get("cancelReason", 0))
            if cancel_reason != 0:
                verification_result.is_canceled = True

            ms_timestamp = result.get("expiryTimeMillis", 0)
            if self._ms_timestamp_expired(ms_timestamp):
                verification_result.is_expired = True
        else:
            result = self.check_purchase_product(purchase_token, product_sku, service)
            verification_result.raw_response = result

            purchase_state = int(result.get("purchaseState", 1))
            if purchase_state != 0:
                verification_result.is_canceled = True

        return verification_result 
開發者ID:dotpot,項目名稱:InAppPy,代碼行數:30,代碼來源:googleplay.py

示例11: perform_operation

# 需要導入模塊: import rsa [as 別名]
# 或者: from rsa import verify [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

示例12: perform_operation

# 需要導入模塊: import rsa [as 別名]
# 或者: from rsa import verify [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

示例13: validate

# 需要導入模塊: import rsa [as 別名]
# 或者: from rsa import verify [as 別名]
def validate(self, bucket, key, public_key, digest_data, inflated_digest):
        """Validates a digest file.

        Throws a DigestError when the digest is invalid.

        :param bucket: Bucket of the digest file
        :param key: Key of the digest file
        :param public_key: Public key bytes.
        :param digest_data: Dict of digest data returned when JSON
            decoding a manifest.
        :param inflated_digest: Inflated digest file contents as bytes.
        """
        try:
            decoded_key = base64.b64decode(public_key)
            public_key = rsa.PublicKey.load_pkcs1(decoded_key, format='DER')
            to_sign = self._create_string_to_sign(digest_data, inflated_digest)
            signature_bytes = binascii.unhexlify(digest_data['_signature'])
            rsa.verify(to_sign, signature_bytes, public_key)
        except PyAsn1Error:
            raise DigestError(
                ('Digest file\ts3://%s/%s\tINVALID: Unable to load PKCS #1 key'
                 ' with fingerprint %s')
                % (bucket, key, digest_data['digestPublicKeyFingerprint']))
        except rsa.pkcs1.VerificationError:
            # Note from the Python-RSA docs: Never display the stack trace of
            # a rsa.pkcs1.VerificationError exception. It shows where in the
            # code the exception occurred, and thus leaks information about
            # the key.
            raise DigestSignatureError(bucket, key) 
開發者ID:gkrizek,項目名稱:bash-lambda-layer,代碼行數:31,代碼來源:validation.py

示例14: setup_services

# 需要導入模塊: import rsa [as 別名]
# 或者: from rsa import verify [as 別名]
def setup_services(self, parsed_globals):
        self._source_region = parsed_globals.region
        # Use the the same region as the region of the CLI to get locations.
        self.s3_client_provider = S3ClientProvider(
            self._session, self._source_region)
        client_args = {'region_name': parsed_globals.region,
                       'verify': parsed_globals.verify_ssl}
        if parsed_globals.endpoint_url is not None:
            client_args['endpoint_url'] = parsed_globals.endpoint_url
        self.cloudtrail_client = self._session.create_client(
            'cloudtrail', **client_args) 
開發者ID:gkrizek,項目名稱:bash-lambda-layer,代碼行數:13,代碼來源:validation.py

示例15: to_verify_with_public_key

# 需要導入模塊: import rsa [as 別名]
# 或者: from rsa import verify [as 別名]
def to_verify_with_public_key(cls, message, signature, public_path=None, public_key=None):
        # 公鑰驗簽
        public_key_obj = cls.load_public_key(public_path, public_key)
        message = cls.check_message(message)
        result = rsa.verify(message, signature, public_key_obj)
        return result 
開發者ID:ss1917,項目名稱:ops_sdk,代碼行數:8,代碼來源:__init__.py


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