Another reorganization
diff --git a/src/hash-helper.h b/src/hash-helper.h
new file mode 100644
index 0000000..ea12f30
--- /dev/null
+++ b/src/hash-helper.h
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012-2013 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ *         Zhenkai Zhu <zhenkai@cs.ucla.edu>
+ */
+
+#ifndef HASH_HELPER_H
+#define HASH_HELPER_H
+
+#include <string.h>
+#include <iostream>
+#include <boost/shared_ptr.hpp>
+#include <boost/exception/all.hpp>
+
+// Other options: VP_md2, EVP_md5, EVP_sha, EVP_sha1, EVP_sha256, EVP_dss, EVP_dss1, EVP_mdc2, EVP_ripemd160
+#define HASH_FUNCTION EVP_sha256
+
+class Hash;
+typedef boost::shared_ptr<Hash> HashPtr;
+
+class Hash
+{
+public:
+  Hash (const void *buf, unsigned int length)
+    : m_length (length)
+  {
+    if (m_length != 0)
+      {
+        m_buf = new unsigned char [length];
+        memcpy (m_buf, buf, length);
+      }
+  }
+
+  static HashPtr
+  FromString (const std::string &hashInTextEncoding);
+
+  static HashPtr
+  FromFileContent (const std::string &hashInTextEncoding);
+  
+  ~Hash ()
+  {
+    if (m_length != 0)
+      delete [] m_buf;
+  }
+  
+  bool
+  IsZero () const
+  {
+    return m_length == 0 ||
+      (m_length == 1 && m_buf[0] == 0);
+  }
+
+  bool
+  operator == (const Hash &otherHash) const
+  {
+    if (m_length != otherHash.m_length)
+      return false;
+    
+    return memcmp (m_buf, otherHash.m_buf, m_length) == 0;
+  }
+
+  const void *
+  GetHash () const
+  {
+    return m_buf;
+  }
+
+  unsigned int
+  GetHashBytes () const
+  {
+    return m_length;
+  }
+  
+private:
+  unsigned char *m_buf;
+  unsigned int m_length;
+
+  Hash (const Hash &) { }
+  Hash & operator = (const Hash &) { return *this; }
+  
+  friend std::ostream &
+  operator << (std::ostream &os, const Hash &digest);
+};
+
+namespace Error {
+struct HashConversion : virtual boost::exception, virtual std::exception { };
+}
+
+
+std::ostream &
+operator << (std::ostream &os, const Hash &digest);
+
+#endif // HASH_STRING_CONVERTER_H