I am working on a project in solidity where i am encode a string to SHA256 hash value, and now i want to decode SHA256 hash value and retrieve the actual data. please help hoe to do it.
Below is the code i using to hash a string.
pragma solidity ^0.4.26;
contract TestShaAlgo {
function getSha256(string str) public view returns (bytes32) {
bytes32 hash = sha256(abi.encodePacked(str));
return hash;
}
}
A hash function is a ONE WAY function, this means that you can't ever get your original data back from the hash.
A hash function is not an encryption function. You can imagine a hash function as a "fingerprint" - it identifies the data, but it's not the data itself.
To encrypt your data, use an encryption function, not a hash function.