title: How do i generate input data for Aadhar card (used by indian citizen as their unique identifier) API integration
body: <p>I am implementing aadhar card api and I got stuck in generating PID and sKey xml block for input xml data, following is the requirement for both key element.</p>
  
  <p>PID block data should be encrypted with a dynamic session key using AES-256 symmetric algorithm (AES/ECB/PKCS7Padding). Session key, in turn, is encrypted with 2048-bit UIDAI public key using asymmetric algorithm (RSA/ECB/PKCS1Padding).</p>
  
  <p>Skey Value of this element is base-64 encoded value of encrypted 256-bit AES session key.</p>
  
  <p>Below is the code what I have created:</p>
  
  <pre><code> /////////////////////
  
  $ci = '20170922';       
  
  $method = 'AES-256-ECB';
  $skey = openssl_encrypt (session_id(), $method ,$ci, true);
  
  $pid_block = '&lt;Pid ts="2016061512000000" ver="1.0"&gt;&lt;Demo lang=""&gt;&lt;Pi ms="E" mv="" name="Shivshankar Choudhury" lname="" lmv="" gender="" dob="" dobt="" age="" phone="" email="" /&gt;&lt;/Demo&gt;&lt;/Pid&gt;';
  $pid_encoded = base64_encode($pid_block);
  $hash_256_pid = hash (  'sha256'  ,  $pid_block);
  $hmac_pid_block = openssl_encrypt($hash_256_pid , $method , session_id());
  $encoded_hmac_pid_block = base64_encode($hmac_pid_block);
  
  
  $xml_data = '&lt;Auth ac="public" sa="public" ver="1.6" txn="706bf70d" tid="public" uid="999999990019"&gt;&lt;Uses pi="y" pa="n" pfa="n" bio="y" bt="FMR" otp="n" pin="n"/&gt;&lt;Meta udc="UIDAI:SampleClient" fdc="NC" idc="NA" pip="127.0.0.1" lot="P" lov="560103"/&gt;&lt;Skey ci="20131003" &gt;'.$skey.'&lt;/Skey&gt;&lt;Data type="X"&gt;'.$pid_encoded.'&lt;/Data&gt;&lt;Hmac&gt;'.$encoded_hmac_pid_block.'&lt;/Hmac&gt;&lt;/Auth&gt;';
  echo $xml_data;
  $url = "http://auth.uidai.gov.in/1.6/public/9/9/";
  
          //setting the curl parameters.
          $ch = curl_init();
          curl_setopt($ch, CURLOPT_URL, $url);
  // Following line is compulsary to add as it is:
          curl_setopt($ch, CURLOPT_POSTFIELDS,
                      "xmlRequest=" . $xml_data);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
          curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300);
          $data = curl_exec($ch);
          curl_close($ch);
  
          //convert the XML result into array
          $array_data = json_decode(json_encode(simplexml_load_string($data)), true);
  </code></pre>