• Home

Compare Strings In Solidity

Best way to compare strings in solidity.


function compareLengthAndHash(string a, string b) internal returns (bool) {
    if(bytes(a).length != bytes(b).length) {
        return false;
    } else {
        return keccak256(a) == keccak256(b);
    }
}

Previous

How to call private functions in solidity?

Next

Function Selectors in Solidity

Get these learning bytes in your email. Dont worry we dont byte.

Vires in Numeris.