Implement hash algorithm