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


Python cryptography.__version__方法代码示例

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


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

示例1: pytest_report_header

# 需要导入模块: import cryptography [as 别名]
# 或者: from cryptography import __version__ [as 别名]
def pytest_report_header(config):
    if OpenSSL is not None:
        openssl_version = OpenSSL.SSL.SSLeay_version(
            OpenSSL.SSL.SSLEAY_VERSION
        ).decode("ascii")
        pyopenssl_version = OpenSSL.__version__
    else:
        openssl_version = "n/a"
        pyopenssl_version = "missing"

    return """\
OpenSSL: {openssl}
pyOpenSSL: {pyOpenSSL}
cryptography: {cryptography}""".format(
        openssl=openssl_version,
        pyOpenSSL=pyopenssl_version,
        cryptography=cryptography.__version__,
    ) 
开发者ID:pyca,项目名称:service-identity,代码行数:20,代码来源:conftest.py

示例2: _should_use_new_crypto_version

# 需要导入模块: import cryptography [as 别名]
# 或者: from cryptography import __version__ [as 别名]
def _should_use_new_crypto_version():
    """
    Checks if this python-cryptography supports the new signing and verifying methods.

    As of version 1.5.x cryptography has the `sign` and `verify` methods.
    As of version 2.x, the `signer` and `verifier` methods have been deprecated.

    :return: whether we should use the new signing/verifying methods
    :rtype: bool
    """
    import cryptography
    from distutils.version import LooseVersion
    try:
        cryptography_version = LooseVersion(cryptography.__version__)
        return cryptography_version >= LooseVersion('1.5')
    except (AttributeError, UnicodeEncodeError):
        # Empty strings raise AttributeError
        # Illegal unicode characters raise UnicodeEncodeError
        return False 
开发者ID:Tribler,项目名称:py-ipv8,代码行数:21,代码来源:__init__.py

示例3: scrapy_components_versions

# 需要导入模块: import cryptography [as 别名]
# 或者: from cryptography import __version__ [as 别名]
def scrapy_components_versions():
    lxml_version = ".".join(map(str, lxml.etree.LXML_VERSION))
    libxml2_version = ".".join(map(str, lxml.etree.LIBXML_VERSION))
    try:
        w3lib_version = w3lib.__version__
    except AttributeError:
        w3lib_version = "<1.14.3"
    try:
        import cryptography
        cryptography_version = cryptography.__version__
    except ImportError:
        cryptography_version = "unknown"

    return [
        ("Scrapy", scrapy.__version__),
        ("lxml", lxml_version),
        ("libxml2", libxml2_version),
        ("cssselect", cssselect.__version__),
        ("parsel", parsel.__version__),
        ("w3lib", w3lib_version),
        ("Twisted", twisted.version.short()),
        ("Python", sys.version.replace("\n", "- ")),
        ("pyOpenSSL", _get_openssl_version()),
        ("cryptography", cryptography_version),
        ("Platform",  platform.platform()),
    ] 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:28,代码来源:versions.py

示例4: _get_openssl_version

# 需要导入模块: import cryptography [as 别名]
# 或者: from cryptography import __version__ [as 别名]
def _get_openssl_version():
    try:
        import OpenSSL
        openssl = OpenSSL.SSL.SSLeay_version(OpenSSL.SSL.SSLEAY_VERSION)\
            .decode('ascii', errors='replace')
    # pyOpenSSL 0.12 does not expose openssl version
    except AttributeError:
        openssl = 'Unknown OpenSSL version'

    return '{} ({})'.format(OpenSSL.version.__version__, openssl) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:12,代码来源:versions.py

示例5: push_subscription_generate_keys

# 需要导入模块: import cryptography [as 别名]
# 或者: from cryptography import __version__ [as 别名]
def push_subscription_generate_keys(self):
        """
        Generates a private key, public key and shared secret for use in webpush subscriptions.
        
        Returns two dicts: One with the private key and shared secret and another with the 
        public key and shared secret.
        """
        if not IMPL_HAS_CRYPTO:
            raise NotImplementedError('To use the crypto tools, please install the webpush feature dependencies.')
        
        push_key_pair = ec.generate_private_key(ec.SECP256R1(), default_backend())
        push_key_priv = push_key_pair.private_numbers().private_value
        
        crypto_ver = cryptography.__version__
        if len(crypto_ver) < 5:
            crypto_ver += ".0"
        if bigger_version(crypto_ver, "2.5.0") == crypto_ver:
            push_key_pub = push_key_pair.public_key().public_bytes(serialization.Encoding.X962, serialization.PublicFormat.UncompressedPoint)
        else:
            push_key_pub = push_key_pair.public_key().public_numbers().encode_point() 
        push_shared_secret = os.urandom(16)
        
        priv_dict = {
            'privkey': push_key_priv,
            'auth': push_shared_secret
        }
        
        pub_dict = {
            'pubkey': push_key_pub,
            'auth': push_shared_secret
        }
        
        return priv_dict, pub_dict 
开发者ID:halcy,项目名称:Mastodon.py,代码行数:35,代码来源:Mastodon.py

示例6: pytest_report_header

# 需要导入模块: import cryptography [as 别名]
# 或者: from cryptography import __version__ [as 别名]
def pytest_report_header(config):
    import OpenSSL.SSL
    import cryptography

    return "OpenSSL: {openssl}\ncryptography: {cryptography}".format(
        openssl=OpenSSL.SSL.SSLeay_version(OpenSSL.SSL.SSLEAY_VERSION),
        cryptography=cryptography.__version__
    ) 
开发者ID:pyca,项目名称:pyopenssl,代码行数:10,代码来源:conftest.py

示例7: main

# 需要导入模块: import cryptography [as 别名]
# 或者: from cryptography import __version__ [as 别名]
def main():
    arg_parser = argparse.ArgumentParser()
    arg_subparser = arg_parser.add_subparsers(help='command')

    cmd_createp = arg_subparser.add_parser('create', help='create ias-image',
                                          formatter_class=argparse.RawTextHelpFormatter)
    cmd_createp.add_argument('-o', '--output', help='output filename')
    cmd_createp.add_argument('-d', '--devkey',
                             help='private key for internal signing - used during development phase (RSA signature and public key will be appended to image)')
    cmd_createp.add_argument('-i', '--imagetype', help='\
image type: 32bit-value decimal [197376] or hexadecimal [0x30300]\n\
 [BIT 31-16: Image type]\n\
 [BIT 15-10: Reserved]\n\
 [BIT 9:     Public Key present]\n\
 [BIT 8:     RSA signature present]\n\
 [BIT 7-0:   Compression algorithm]\n\
 Image type - BIT field:\n\
  [3 : Multi-file boot image]\n\
  [4 : ELF Multiboot compliant boot image]\n\
  [5 : SPI update package]\n\
  [6 : ABL configuration image]\n\
  [7 : MRC training parameter]\n\
  [8 : IFWI update package]\n\
  [9 : PDR update package]\n\
  [10: Firmware package]\n\
  [11: Pre-OS checker image]')
    cmd_createp.add_argument('-p', '--page-aligned', default=None, const='0', nargs='?',
                             help='file number before which image should be page aligned')
    cmd_createp.add_argument('-v', '--verbose', action='count')
    cmd_createp.add_argument('file', nargs='+')
    cmd_createp.set_defaults(output='iasImage')
    cmd_createp.set_defaults(verbose=0)
    cmd_createp.set_defaults(func=cmd_create)

    cmd_signp = arg_subparser.add_parser('sign', help='sign ias-image')
    cmd_signp.add_argument('-o', '--output', help='output filename')
    cmd_signp.add_argument('-k', '--key', help='public key')
    cmd_signp.add_argument('-s', '--signature', required=True, help='RSA signature')
    cmd_signp.add_argument('file')
    cmd_signp.set_defaults(output='iasImage')
    cmd_signp.set_defaults(func=cmd_sign)

    cmd_extractp = arg_subparser.add_parser('extract', help='extract ias-image components')
    cmd_extractp.add_argument('file')
    cmd_extractp.set_defaults(func=cmd_extract)

    arg_parser.add_argument('-V', '--version', action='version', version='%(prog)s ' + __version__)

    args = arg_parser.parse_args()
    if not 'func' in args:
        arg_parser.print_usage()
        sys.exit(2)
    sys.exit(args.func(args)) 
开发者ID:intel,项目名称:iasimage,代码行数:55,代码来源:iasimage.py


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