title: generate AC cryptogram manually
body: <p>I am trying to generate AC manually, I have a tool to generate AC but I want to generate it by my own to understand the algorithm for the same.</p>
  
  <p>My calculation is fine for Discover card but it is failing for MasterCard. As per my understanding, data used to generate AC is depend on Tag 8C - CDOL1 which we provide to card with Gen AC command + AIP + ATC.</p>
  
  <p>AIP and ATC - accessed internally by ICC.</p>
  
  <p>Data used to generate AC is:-</p>
  
  <pre><code>data part of Gen AC command + value of tag 82 + value of tag 9f36 + 80 + optional 00 to make it multiple of 8.
  </code></pre>
  
  <p>this is my logic ,it might be I am using wrong data to calculate A.C that's why getting different result from my test tool.</p>
  
  <p>Terminal Supplied Data<br>
  Amount, Authorised - 000000000201<br>
  Amount, Other - 000000000000<br>
  Terminal Country Code - 0826 - United Kingdom<br>
  Terminal Verification Results - 00 00 00 00 00<br>
  Transaction Currency Code - 0826 - Pound Sterling<br>
  Transaction Date - 15 04 28<br>
  Transaction Type - 00 - Goods and Services<br>
  Unpredictable Number - 30 90 1B 6A<br>
  Terminal Type - 23 - Attended, offline only. Operated by Merchant<br>
  Data Authentication Code - 00 00<br>
  ICC Dynamic Number - 1E AB C1 26 F8 54 99 76<br>
  CVM Results - 00 00 00  </p>
  
  <p>Gen AC Using CDOL1
  80 AE 40 00 2B 0000000002010000000000000826000000000008261504280030901B6A2300001EABC126F8549976000000
  this command is returning 9F26. 
  data i used for calcatation is:-  </p>
  
  <p>0000000002010000000000000826000000000008261504280030901B6A2300001EABC126F8549976000000<strong>3800000180</strong> [ data is multiple of 8] </p>
  
  <p>Where 3800 is AIP 0001 is ATC and 80 for Padding [ Padding method 2 EMV] This is my logic, Is any body tell me where I should focus more to generate same AC as my tool generated.</p>