Calculate hash length only once