Add Strings.equal (#3774)

Co-authored-by: Francisco <fg@frang.io>
This commit is contained in:
Matteo Casonato
2022-12-28 22:23:24 +01:00
committed by GitHub
parent f799475d93
commit 7a6a9d1516
4 changed files with 37 additions and 0 deletions

View File

@ -67,4 +67,11 @@ library Strings {
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}