added sha256 and sha 512
removed duplicate code
added null checks for hash functions