我目前正在尝试使用md5哈希创建唯一的网址。我知道这项技术正在变得多余,但对于我的预期用途并不需要很复杂。
string offerURL = HttpContext.Current.Server.UrlEncode(KookConfiguration.ConfigurationManager.AppSettings["live_sURL"] + "offer/" + offerTitle.Replace(" ", "") + "-" + offerID + ".aspx");
string uniqueOfferFB = offerURL + "%3Fshareid=" + userID.ToString() + "-" + offerID.ToString() + "-" + TypeID.ToString() + "-FB"; //Facebook
string uniqueOfferTW = offerURL + "%3Fshareid=" + userID.ToString() + "-" + offerID.ToString() + "-" + TypeID.ToString() + "-TW"; //Twitter
string uniqueOfferEM = offerURL + "%3Fshareid=" + userID.ToString() + "-" + offerID.ToString() + "-" + TypeID.ToString() + "-EM" + "%0D%0A%0D%0A" + "Sent from the sample.com website"; //Email
//md5 facebook
byte[] encodedUniqueOfferFB = new UTF8Encoding().GetBytes(uniqueOfferFB);
byte[] FBhash = ((HashAlgorithm)CryptoConfig.CreateFromName("MD5")).ComputeHash(encodedUniqueOfferFB);
//md5 Twitter
byte[] encodedUniqueOfferTW = new UTF8Encoding().GetBytes(uniqueOfferTW);
byte[] TWhash = ((HashAlgorithm)CryptoConfig.CreateFromName("MD5")).ComputeHash(encodedUniqueOfferTW);
//md5 Email
byte[] encodedUniqueOfferEM = new UTF8Encoding().GetBytes(uniqueOfferEM);
byte[] EMhash = ((HashAlgorithm)CryptoConfig.CreateFromName("MD5")).ComputeHash(encodedUniqueOfferEM);