hash function, endian reversal functions