I think there's a validate_hash available in stdlib.