type:
integration
supports-foxycart-version-from:
0.7.2
system:
ASP.Net, C#
name:
Cart Validation helper code for ASP.net/cSharp
description:
Includes code for hashing with SHA1
tags:
cSharp, .net, asp, hmac, cart validation

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 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();
}

Site Tools