code for hash
this should gop in sopme library..
its not tested till now