开发者

Hash values not printing in python

The original ques was Use this pattern to implement a family of classes each of which has the following behaviour

reads开发者_JAVA技巧 a file (for simplicity, we assume a single line within the file) generates a hash value encrypt the file's contents, given a key(s) The class should store the unencrpyted text, the hash value and the encrypted text. The constructor of the class should generate the key(s) required.

All classes do the same thing except differ in their implementation. Techniques for each class are below

hashing technique MD5, encryption technique AES hashing technique SHA-1, encryption technique AES hashing technique SHA-2, encryption technique RSA

Were expecting to print the hash value for each of the functions but it shows nothing,


import hashlib


class LineToHash:

    HashString = "Brazil is taking home this world cup !"


class GeneratingHash:

    def hashgeneratormd5(HashString):
        hash_object_md5 = hashlib.md5(LineToHash.HashString.encode())
        print(hash_object_md5.hexdigest())

    def hashgeneratorsha1(HashString):
        hash_object_sha1 = hashlib.sha1(LineToHash.HashString.encode())
        hex_dig = hash_object_sha1.hexdigest()
        print(hex_dig)

    def hashgeneratorsha2(HashString):
        hash_object_sha2 = hashlib.sha224(LineToHash.HashString.encode())
        hex_dig = hash_object_sha2.hexdigest()
        print(hex_dig)

    def hashgeneratorsha22(HashString):
        hash_object_sha22 = hashlib.sha256(LineToHash.HashString.encode())
        hex_dig = hash_object_sha22.hexdigest()
        print(hex_dig)

'''

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜