The following code is part of a bigger project:
# Todo: automatically generate dict based
# on hashlib.algorithms_available
algorithms = {"md5":hashlib.md5,
"sha1":hashlib.sha1,
"sha224":hashlib.sha224,
"sha256":hashlib.sha256,
"sha384":hashlib.sha384,
"sha512":hashlib.sha512,
"sha3_224":hashlib.sha3_224,
"sha3_256":hashlib.sha3_256,
"sha3_384":hashlib.sha3_384,
"sha3_512":hashlib.sha3_512,
}
self.algo, algorithms = algorithms[self.algo], None
I am trying to use hashlib's algorithms_available
(hashlib.algorithms_available
) to create a custom dictionary, system-dependent. The key:value
pair should be like 《algorithm name》: hashlib.《algorithm》
, but I can't figure it out.