building random hash and sending it back to the client