Is a hash function a RO function or will there be a chance that the hash function will alter the file (as part of function or on accident) that it is hashing?
A hash function works on data, i.e. input and output data. If the data come from a file or network or similar and if they get written to a file or somewhere else has nothing to do with the hash function itself but with a program which uses this hash function for a particular purpose. This purpose can be be to only print the resulting hash value to stdout without modifying the input file. But a hash function can also be used in the process of adding a signature to some section of a file, in which case the file gets modified.
In the general case, creating a hash of a file would not modify the original file.
For example in linux the
md5sum command can be used to create a hash of a file.
user@host:/etc$ md5sum /etc/hosts
the hash is printed back to the screen and doesn't modify the original file.
There are two parts to a file: The file contents (including the primary and alternate streams), and the metadata about the file. Hashing a file will not change the file contents, but it may change the file metadata. So if your intent was to get the hash of a file and not have anyone know that you have done that, then the metadata might give it away. As an example on Windows, when you access a file you end up changing the file's last access date.
You asked if it could alter it on accident... yes, but it would have to be a very big accident (or a very malicious, and very stupid coder).
A program which hashes a file needs to read that file. This means it has to open it. Files must be opened for reading or writing or both. A file opened for reading cannot be written to. A file opened for writing cannot be read. So it's extremely unlikely this sort of mistake would happen, let alone pass even the most basic testing.
OTOH a malicious coder could try to alter your file. This is an extremely unlikely attack as it will be blindingly obvious what's happened, and also blindingly obvious in the code. That code wouldn't last long.
You can protect against this with file permissions, make the file read-only and the program cannot write to it (some operating systems and filesystems may allow the file owner or superuser to write anyway). However if the program is run by the owner of the file, the program can change the file's permissions, alter the file, and change it back. That includes all its metadata. Like I said, this sort of bluntly malicious code extremely easy to spot and extremely unlikely to exist in the wild.
The real answer is to use reputable, reviewed, well-tested crypto software and not something you copied off the Internet.