I want to generate a hash code for a file. Using C# I would do something like this then store the value in a database.
byte[] b = File.ReadAllBytes(@"C:\image.jpg");
string hash = ComputeHash(b);
Now, if i use say a Java program that implements the same hashing alogorithm (Md5), can i expect the hash values to be the equal to the value generated in C#? What if i execute the java program from different environments, Windows, Linux or Mac?
Hash values are not globally unique. But that is not what you are really asking.
What you really want to know is whether a hashing algorithm (such as MD5) will produce the same hash value for identical files on different operating system platforms. The answer to that question is "yes" … provided that files are byte-for-byte identical.
In the case of binary files, they should be byte-for-byte identical. In the case of text documents, transcoding between different character encodings, or changing line termination sequences will make the files different at the byte level and result in different MD5 hash values.