Posts

Showing posts from January, 2020

SHA in Python

Image
  Code Example SHA, ( Secure Hash Algorithms ) are set of cryptographic hash functions defined by the language to be used for various applications such as password security etc. Some variants of it are supported by Python in the “ hashlib ” library. These can be found using “algorithms_guaranteed” function of hashlib. # test.py import hashlib def Encode_SHA256(data='kuntal'):     result = hashlib.sha256(data.encode())     return result.hexdigest() def Encode_SHA384(data='kuntal'):     result = hashlib.sha384(data.encode())     return result.hexdigest() def Encode_SHA224(data='kuntal'):     result = hashlib.sha224(data.encode())     return result.hexdigest() def Encode_SHA512(data='kuntal'):     result = hashlib.sha512(data.encode())     return result.hexdigest() print("SHA256") print(Encode_SHA256(), "len is : ", len(Encode_SHA256())) print("\nSHA384") print(Encode_SHA384(), "len is : ", len(Encode_SHA384())) prin