CalculateHash returns error message instead of output inside the function