Posts

Showing posts with the label encryption

MD5 Hashing in Python

Image
Code Example This hash function accepts a sequence of bytes and returns  128-bit hash value , usually used to check data integrity but has security issues.  There are many hash functions defined in the “ hashlib ” library in python. # What is Hash? Hash is a function that takes a variable-length sequence of bytes as input and converts it to a fixed-length sequence. However, to get your original data(input bytes) back is not easy. For example, x is your input and f is the f is the hashing function, then calculating f(x) is quick and easy but trying to obtain x again is a very time-consuming job.   {'md4', 'sha512', 'sha3_512', 'whirlpool', 'sha1', 'sha3_256', 'sha3_384', 'mdc2', 'ripemd160', 'md5-sha1', 'sha3_224', 'md5', 'shake_128', 'sha512_224', 'shake_256', 'blake2b', 'sha224', 'sha512_256', 'sm3', 'blake2s', 'sha256'...

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_SHA...