contract Cryptography {

  /**
  * @dev Recover signer address from a message by using their signature
  * @param hash message, the hash is the signed message. What is recovered is the signer address.
  * @param signature generated using web3.eth.account.sign().signature
  *
  * Based on https://gist.github.com/axic/5b33912c6f61ae6fd96d6c4a47afde6d
  * TODO: Remove this library once solidity supports passing a signature to ecrecover.
  * See https://github.com/ethereum/solidity/issues/864
  */
  function recover(bytes32 hash, bytes memory signature) public pure returns (address) {
    bytes32 r;
    bytes32 s;
    uint8 v;
    if (signature.length != 65) return (address(0x0));
    // Check the signature length

    // Divide the signature into r, s and v variables
    assembly {
      r := mload(add(signature, 32))
      s := mload(add(signature, 64))
      v := byte(0, mload(add(signature, 96)))
    }

    // Version of signature should be 27 or 28, but 0 and 1 are also possible versions
    if (v < 27) v += 27;

    // If the version is correct return the signer address
    return (v != 27 && v != 28) ? (address(0)) : ecrecover(hash, v, r, s);
  }

}
function recover(bytes32 hash, bytes memory signature) public pure returns (address) {
  bytes32 r;
  bytes32 s;
  uint8 v;
  if (signature.length != 65) return (address(0x0));
  // Check the signature length

  // Divide the signature into r, s and v variables
  assembly {
    r := mload(add(signature, 32))
    s := mload(add(signature, 64))
    v := byte(0, mload(add(signature, 96)))
  }

  // Version of signature should be 27 or 28, but 0 and 1 are also possible versions
  if (v < 27) v += 27;

  // If the version is correct return the signer address
  return (v != 27 && v != 28) ? (address(0)) : ecrecover(hash, v, r, s);
}

/**
 * @dev Recover signer address from a message by using their signature
 * @param hash message, the hash is the signed message. What is recovered is the signer address.
 * @param signature generated using web3.eth.account.sign().signature
 *
 * Based on https://gist.github.com/axic/5b33912c6f61ae6fd96d6c4a47afde6d
 * TODO: Remove this library once solidity supports passing a signature to ecrecover.
 * See https://github.com/ethereum/solidity/issues/864
 */