MATLAB: How to apply hash on a string.

hash

How can i apply hash function on a string and reverse process to generate the same string from the hash value.

Best Answer

Hashing is not a reversible process. You can do encoding and decoding. For example
A = 'The quick brown fox jumps over the lazy dog';
encoded_str = matlab.net.base64encode(A);
decoded_str = char(matlab.net.base64decode(encoded_str));
Result
>> encoded_str
encoded_str =
'VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw=='
>> decoded_str
decoded_str =
'The quick brown fox jumps over the lazy dog'