Hash functions in pure javascript