I've trying to encrypt my data using asymmetric encryption. I've chosen MD5 as the algorithm. PS: I know about MD5 collisions.
I'm following this blog to encrypt and decrypt my data. This uses SHA256. I'm able to run the code successfully with SHA1, SHA512 as well, but not with MD5.
Whenever, I change the algorithm to MD5, it says
cryptography.exceptions.UnsupportedAlgorithm: This combination of padding and hash algorithm is not supported by this backend.
Which padding should be used to encrypt the data with MD5?
My Code:-
# ########## Encrypting and decrypting ##########
message = b'encrypt me!'
encrypted = public_key.encrypt(
message,
padding.OAEP(
mgf=padding.MGF1(algorithm=hashes.MD5()),
algorithm=hashes.MD5(),
label=None
)
)
original_message = private_key.decrypt(
encrypted,
padding.OAEP(
mgf=padding.MGF1(algorithm=hashes.MD5()),
algorithm=hashes.MD5(),
label=None
)
)