---- dataentry integration ---- type : integration # do not change this line supports-foxycart-version-from : 0.7.2 # Minimum required FoxyCart version for this to work supports-foxycart-version-to : # Last FoxyCart version that supports this (leave empty if unknown) systems : ASP.Net, C\# # # the system(s) that the integration is for, separated with commas if more than one name : Cart Validation helper code for ASP.net/cSharp # the name of the integration description : Includes code for hashing with SHA1 # tags_tags : cSharp, .net, asp, hmac, cart validation # tags, separated by commas. don't include the "system" here. date_dt : # the date in YYYY-MM-DD format version : # if you have a version for your code, enter it here developer_url : # if you'd like a link back to your site, stick it here ---- ====== Cart Validation Helpers ====== //**Please note:**// The code on this page is submitted by members of the FoxyCart community, and may not verified by FoxyCart.com LLC in any way, shape, or form. Please double check the code before installing. If you need help with it please [[http://forum.foxycart.com/|post in our forum]], but if we cannot offer assistance (due to unfamiliarity with this particular system or language) we apologize in advance. ==== HMAC Hashing for Cart Validation ==== public string HashWithHmac(string contentToHash) { var key = Encoding.UTF8.GetBytes(_FoxyCartConfig.ApiKey); var sha256 = new HMACSHA256(key); var hashData = sha256.ComputeHash(Encoding.UTF8.GetBytes(contentToHash)); var stringBuilder = new StringBuilder(); foreach (var hd in hashData) { stringBuilder.Append(hd.ToString("x2")); } return stringBuilder.ToString(); }