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


Python Hash.SHA512屬性代碼示例

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


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

示例1: get_tests_SHA512

# 需要導入模塊: from Crypto import Hash [as 別名]
# 或者: from Crypto.Hash import SHA512 [as 別名]
def get_tests_SHA512():

    test_vectors = load_tests(("Crypto", "SelfTest", "Hash", "test_vectors", "SHA2"),
                                "SHA512ShortMsg.rsp",
                                "KAT SHA-512",
                                { "len" : lambda x: int(x) } )

    test_data = test_data_512_other[:]
    for tv in test_vectors:
        try:
            if tv.startswith('['):
                continue
        except AttributeError:
            pass
        if tv.len == 0:
            tv.msg = b""
        test_data.append((hexlify(tv.md), tv.msg, tv.desc))

    tests = make_hash_tests(SHA512, "SHA512", test_data,
                            digest_size=64,
                            oid="2.16.840.1.101.3.4.2.3")
    return tests 
開發者ID:vcheckzen,項目名稱:FODI,代碼行數:24,代碼來源:test_SHA512.py

示例2: get_tests_SHA512_224

# 需要導入模塊: from Crypto import Hash [as 別名]
# 或者: from Crypto.Hash import SHA512 [as 別名]
def get_tests_SHA512_224():

    test_vectors = load_tests(("Crypto", "SelfTest", "Hash", "test_vectors", "SHA2"),
                                "SHA512_224ShortMsg.rsp",
                                "KAT SHA-512/224",
                                { "len" : lambda x: int(x) } )

    test_data = []
    for tv in test_vectors:
        try:
            if tv.startswith('['):
                continue
        except AttributeError:
            pass
        if tv.len == 0:
            tv.msg = b""
        test_data.append((hexlify(tv.md), tv.msg, tv.desc))

    tests = make_hash_tests(SHA512, "SHA512/224", test_data,
                            digest_size=28,
                            oid="2.16.840.1.101.3.4.2.5",
                            extra_params={ "truncate" : "224" })
    return tests 
開發者ID:vcheckzen,項目名稱:FODI,代碼行數:25,代碼來源:test_SHA512.py

示例3: get_tests_SHA512_256

# 需要導入模塊: from Crypto import Hash [as 別名]
# 或者: from Crypto.Hash import SHA512 [as 別名]
def get_tests_SHA512_256():

    test_vectors = load_tests(("Crypto", "SelfTest", "Hash", "test_vectors", "SHA2"),
                                "SHA512_256ShortMsg.rsp",
                                "KAT SHA-512/256",
                                { "len" : lambda x: int(x) } )

    test_data = []
    for tv in test_vectors:
        try:
            if tv.startswith('['):
                continue
        except AttributeError:
            pass
        if tv.len == 0:
            tv.msg = b""
        test_data.append((hexlify(tv.md), tv.msg, tv.desc))

    tests = make_hash_tests(SHA512, "SHA512/256", test_data,
                            digest_size=32,
                            oid="2.16.840.1.101.3.4.2.6",
                            extra_params={ "truncate" : "256" })
    return tests 
開發者ID:vcheckzen,項目名稱:FODI,代碼行數:25,代碼來源:test_SHA512.py

示例4: runTest

# 需要導入模塊: from Crypto import Hash [as 別名]
# 或者: from Crypto.Hash import SHA512 [as 別名]
def runTest(self):

        key = RSA.generate(1024)
        signer = pkcs1_15.new(key)
        hash_names = ("MD2", "MD4", "MD5", "RIPEMD160", "SHA1",
                      "SHA224", "SHA256", "SHA384", "SHA512",
                      "SHA3_224", "SHA3_256", "SHA3_384", "SHA3_512")

        for name in hash_names:
            hashed = load_hash_by_name(name).new(b"Test")
            signer.sign(hashed)

        from Crypto.Hash import BLAKE2b, BLAKE2s
        for hash_size in (20, 32, 48, 64):
            hashed_b = BLAKE2b.new(digest_bytes=hash_size, data=b"Test")
            signer.sign(hashed_b)
        for hash_size in (16, 20, 28, 32):
            hashed_s = BLAKE2s.new(digest_bytes=hash_size, data=b"Test")
            signer.sign(hashed_s) 
開發者ID:bkerler,項目名稱:android_universal,代碼行數:21,代碼來源:test_pkcs1_15.py

示例5: runTest

# 需要導入模塊: from Crypto import Hash [as 別名]
# 或者: from Crypto.Hash import SHA512 [as 別名]
def runTest(self):

        key = RSA.generate(1280)
        signer = pss.new(key)
        hash_names = ("MD2", "MD4", "MD5", "RIPEMD160", "SHA1",
                      "SHA224", "SHA256", "SHA384", "SHA512",
                      "SHA3_224", "SHA3_256", "SHA3_384", "SHA3_512")

        for name in hash_names:
            hashed = load_hash_by_name(name).new(b("Test"))
            signer.sign(hashed)

        from Crypto.Hash import BLAKE2b, BLAKE2s
        for hash_size in (20, 32, 48, 64):
            hashed_b = BLAKE2b.new(digest_bytes=hash_size, data=b("Test"))
            signer.sign(hashed_b)
        for hash_size in (16, 20, 28, 32):
            hashed_s = BLAKE2s.new(digest_bytes=hash_size, data=b("Test"))
            signer.sign(hashed_s) 
開發者ID:bkerler,項目名稱:android_universal,代碼行數:21,代碼來源:test_pss.py

示例6: get_tests

# 需要導入模塊: from Crypto import Hash [as 別名]
# 或者: from Crypto.Hash import SHA512 [as 別名]
def get_tests(config={}):
    from Crypto.Hash import SHA512
    from common import make_hash_tests
    return make_hash_tests(SHA512, "SHA512", test_data,
        digest_size=64,
        oid="\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x03") 
開發者ID:mortcanty,項目名稱:earthengine,代碼行數:8,代碼來源:test_SHA512.py

示例7: get_tests

# 需要導入模塊: from Crypto import Hash [as 別名]
# 或者: from Crypto.Hash import SHA512 [as 別名]
def get_tests(config={}):
    global test_data
    from Crypto.Hash import HMAC, MD5, SHA as SHA1, SHA256
    from common import make_mac_tests
    hashmods = dict(MD5=MD5, SHA1=SHA1, SHA256=SHA256, default=None)
    try:
        from Crypto.Hash import SHA224, SHA384, SHA512
        hashmods.update(dict(SHA224=SHA224, SHA384=SHA384, SHA512=SHA512))
        test_data += hashlib_test_data
    except ImportError:
        import sys
        sys.stderr.write("SelfTest: warning: not testing HMAC-SHA224/384/512 (not available)\n")
    return make_mac_tests(HMAC, "HMAC", test_data, hashmods) 
開發者ID:mortcanty,項目名稱:earthengine,代碼行數:15,代碼來源:test_HMAC.py

示例8: test3

# 需要導入模塊: from Crypto import Hash [as 別名]
# 或者: from Crypto.Hash import SHA512 [as 別名]
def test3(self):
        # Verify that hmac_hash_module works like prf

        password = b("xxx")
        salt = b("yyy")

        for hashmod in (MD5, SHA1, SHA224, SHA256, SHA384, SHA512):

            pr1 = PBKDF2(password, salt, 16, 100,
                         prf=lambda p, s: HMAC.new(p,s,hashmod).digest())
            pr2 = PBKDF2(password, salt, 16, 100, hmac_hash_module=hashmod)

            self.assertEqual(pr1, pr2) 
開發者ID:vcheckzen,項目名稱:FODI,代碼行數:15,代碼來源:test_KDF.py

示例9: add_tests

# 需要導入模塊: from Crypto import Hash [as 別名]
# 或者: from Crypto.Hash import SHA512 [as 別名]
def add_tests(self, filename):
        comps = "Crypto.SelfTest.Protocol.test_vectors.wycheproof".split(".")
        with open(pycryptodome_filename(comps, filename), "rt") as file_in:
            tv_tree = json.load(file_in)

        algo_name = tv_tree['algorithm']
        if algo_name == "HKDF-SHA-1":
            hash_module = SHA1
        elif algo_name == "HKDF-SHA-256":
            hash_module = SHA256
        elif algo_name == "HKDF-SHA-384":
            hash_module = SHA384
        elif algo_name == "HKDF-SHA-512":
            hash_module = SHA512
        else:
            raise ValueError("Unknown algorithm " + algo_name)

        for group in tv_tree['testGroups']:

            from collections import namedtuple
            TestVector = namedtuple('TestVector', 'id comment ikm salt info size okm hash_module valid warning filename')

            for test in group['tests']:
                tv = TestVector(
                    test['tcId'],
                    test['comment'],
                    unhexlify(test['ikm']),
                    unhexlify(test['salt']),
                    unhexlify(test['info']),
                    int(test['size']),
                    unhexlify(test['okm']),
                    hash_module,
                    test['result'] != "invalid",
                    test['result'] == "acceptable",
                    filename
                )
                self.tv.append(tv) 
開發者ID:vcheckzen,項目名稱:FODI,代碼行數:39,代碼來源:test_KDF.py

示例10: get_hash_module

# 需要導入模塊: from Crypto import Hash [as 別名]
# 或者: from Crypto.Hash import SHA512 [as 別名]
def get_hash_module(hash_name):
    if hash_name == "SHA-512":
        hash_module = SHA512
    elif hash_name == "SHA-384":
        hash_module = SHA384
    elif hash_name == "SHA-256":
        hash_module = SHA256
    elif hash_name == "SHA-224":
        hash_module = SHA224
    elif hash_name == "SHA-1":
        hash_module = SHA1
    else:
        raise ValueError("Unknown hash algorithm: " + hash_name)
    return hash_module 
開發者ID:bkerler,項目名稱:android_universal,代碼行數:16,代碼來源:test_pss.py


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