How to sign and verify a message

Hello everyone, I really need help with this.

I want to check if a message was signed by an address.
The address that signed the message is: 0xeac9852225Aa941Fa8EA2E949e733e2329f42195
The message is: "0x7b50414CBC68553fCA2b078d9AdEE183f10bDfcF"

This is the code of my Smart Contract:

// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/eae238417862b4797e36fbff928d906bb9242261/contracts/utils/cryptography/ECDSA.sol";
contract VerifySignature {
    using ECDSA for bytes32; 

    function verifyMessage(string memory message, bytes memory signature) public view  returns(address, bool) {
        //hash the plain text message
        bytes32 messagehash =  keccak256(bytes(message));
       
        address signeraddress = messagehash.toEthSignedMessageHash().recover(signature);
              
        if (msg.sender==signeraddress) {
            //The message is authentic
            return (signeraddress, true);
        } else {
            //msg.sender didnt sign this message.
            return (signeraddress, false);
        }
    }
  
}

I'm using remix but I'm struffle because the result is alwasy false!
This is the input of the contract:

message: 0x7b50414CBC68553fCA2b078d9AdEE183f10bDfcF
signature: 0x03bd84a511ddf366d5b2da34b3821c6492493ad78eacd778c3df6630f609d61e2718078c324ec5d6129defbbdc51a78bb2f8f77eadc05bbb27620e6bef30bd7a1c

As you can see here:

can someone help me please?
I've tried really a lot of different ways and it would mean the world to me.
Thanks.

It's probably the way you are signing the the message. take a look at this post

1 Like