C++/HashLib: Refactor, remove some redundance code