private static string CreateString(MD5HashProperties objMD5HashProperties) { StringBuilder sbTemp = new StringBuilder(); sbTemp.Append(objMD5HashProperties.MAC_Address); sbTemp.Append(","); sbTemp.Append(objMD5HashProperties.SystemHost); sbTemp.Append(","); sbTemp.Append(objMD5HashProperties.SystemID); sbTemp.Append(","); sbTemp.Append(objMD5HashProperties.SchoolSecurityCode); return(sbTemp.ToString()); //if (objMD5HashProperties.MAC_Address.Trim() != string.Empty && // objMD5HashProperties.SchoolSecurityCode.Trim() != string.Empty && // objMD5HashProperties.SystemHost.Trim() != string.Empty && // objMD5HashProperties.SystemID.Trim() != string.Empty) //{ // StringBuilder sbTemp = new StringBuilder(); // sbTemp.Append(objMD5HashProperties.MAC_Address); // sbTemp.Append(","); // sbTemp.Append(objMD5HashProperties.SystemHost); // sbTemp.Append(","); // sbTemp.Append(objMD5HashProperties.SystemID); // sbTemp.Append(","); // sbTemp.Append(objMD5HashProperties.SchoolSecurityCode); // return sbTemp.ToString(); //} //else //{ // throw new Exception("String can not generate."); //} }
public string GenerateMD5Hash(MD5HashProperties objMD5HashProperties) { try { byte[] bMD5Hash = new MD5CryptoServiceProvider().ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(CreateString(objMD5HashProperties))); StringBuilder sOutput = new StringBuilder(bMD5Hash.Length); for (int i = 0; i < bMD5Hash.Length; i++) { sOutput.Append(bMD5Hash[i].ToString("X2")); } return(sOutput.ToString()); } catch { return(string.Empty); } }