using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;

namespace SampleServiceNamespace
{
  /// <summary>
  /// String.GetHashCode is not guaranteed to work same on 32, 64bit and different versions of .NET
  /// (it is known it doesn't)
  /// </summary>
  public class PortableHash
  {

    public static string GetHash(string value)
    {
      return GetHash(new string[] { value });
    }

    public static string GetHash(string[] inputArr)
    {
      StringBuilder sb = new StringBuilder("dm");
      for (int i = 0; i < inputArr.Length; i++)
      {
        sb.Append(inputArr[i].ToLower());
      }
      return sb.ToString();
      //StringBuilder sbResult = new StringBuilder();
      //StringBuilder sbInput = new StringBuilder();
      //sbInput.Append("hjg345h5jh*&^^G**JKH!@KJB{}PO"); // garbage, for security...
      //for (int i = 0; i < inputArr.Length; i++)
      //{
      //  sbInput.Append(inputArr[i].ToLower());
      //}
      //using (MD5 md5Hash = MD5.Create())
      //{
      //  // Convert the input string to a byte array and compute the hash. 
      //  byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(sbInput.ToString()));
      //  // Loop through each byte of the hashed data  
      //  // and format each one as a hexadecimal string. 
      //  for (int i = 0; i < data.Length; i++)
      //  {
      //    sbResult.Append(data[i].ToString("x2"));
      //  }
      //  // Return the hexadecimal string. 
      //}
      //return sbResult.ToString();
    }
  }
}
