In the field of information security, hash functions are considered important as they are used to ensure message integrity and authentication. Despite various available methods to design hash functions, the methods have been proven to time inefficient and have security flaws (such as a lack of collision resistance or susceptibility to birthday attacks). In the current study, we propose a novel hash function scheme based on a new Mersenne number transform. The suggested hash function called Hash Mersenne Number Transform (HMNT) takes an arbitrary length as input to generate a hash value with variable lengths (128, 256 and 512-bits or longer). The proposed scheme is evaluated in terms of the sensitivity of the hash value to the message, secret key and image, distribution of hashes, confusion and diffusion, robustness against collision and birthday attacks, alongside flexibility. Based on the simulation outcomes, the suggested scheme possess high sensitivity to the original message, the secret key and images, along with strong collision resistance. In conclusion, the proposed hash scheme is simple and efficient compared with the existing hash functions, making it viable for practical implementation.