public synchronized boolean isValid(){
		try {
			MessageDigest hasher = MessageDigest.getInstance("SHA");
			byte[] result = hasher.digest(this.getData());
			hasher.reset();
			if(result.length != hash.length){
				System.err.println("Hash check for piece " + this.index + " failed with hash length mismatch.");
				return false;
			}
			//System.out.println("hash-"+ (new String(hash)));
			//System.out.println("newh-"+ (new String(result)));
			for(int i = 0; i < result.length; i++){
				if(result[i] != hash[i]){
					System.err.println("Hash check for piece " + this.index + " failed at byte " + i + ".");
					return false;
				}
			}
		} catch (NoSuchAlgorithmException e) {
			System.err.println("Unable to check hash of piece. Invalid Algorithm");
		} 
		return true;
	}