AnsweredAssumed Answered

Getting Munchkin API associateLead call to work SHA1 hash issues

Question asked by 35236 on Nov 6, 2013
Latest reply on Mar 19, 2014 by 9634
Hi all,

I've been following the instructions and discussions within the community to write the associateLead call from the Munchkin Javascript API. However I'm having trouble generating the SHA1 hash... Could anyone help, please? I'm using ASP.NET.

Here's the instructions I've been following (About half way down the page):

The specific problem I'm having is debugging the script that generates the SHA1 hash - I know that the AssociateLead function works itself as i've tried hardcoding an email address and generating a SHA1 hash using a web app generator.

Once I know the SHA1 generation code is working, I then need to figure out how to pass that value/string into the AssociateLead function.

All help appriciated! Thank you! 

Here's my code so far:

<script src="" type="text/javascript"></script>
Email: '@formModel.Email',
FirstName: '@formModel.FirstName',
LastName: '@formModel.Surname',
Company: '@formModel.Company',
Title: '@formModel.Position',
Phone: '@formModel.Telephone',
Address: '@formModel.CompanyAddress1',
City: '@formModel.CompanyTownCity',
PostalCode: '@formModel.CompanyPostcode',
Country: '@formModel.Country',
Industry: '@formModel.Industry',
Solution_interest__c: '@formModel.Solution',
Purchase_authority__c: '@formModel.Authority',
Key_business_challenges__c: '@formModel.Objectives',
Unsubscribed: '@formModel.NewsLetter'},

     and the recommended code for dynamically generating the SHA1 (added email variable)...
string GetEncryptedEmail(string emailAddress) { <-- Do I need to change this?   -->
string encryptedEmail = "";
string apiKeyEmail = 'PrivateKeyRemoved' + '@formModel.Email';
byte[] input = Encoding.UTF8.GetBytes(apiKeyEmail);
byte[] hash = null;
SHA1 sha = new SHA1CryptoServiceProvider();
hash = sha.ComputeHash(input);
encryptedEmail = BitConverter.ToString(hash).Replace("-", "");
return encryptedEmail.ToLower();