如何生成Aadhar卡的输入数据(由印度公民使用作为他们的唯一标识符)API集成
问题描述:
我正在实施aadhar卡api,并且我陷入了生成输入xml数据的PID和sKey xml块,以下是要求为这两个关键因素。如何生成Aadhar卡的输入数据(由印度公民使用作为他们的唯一标识符)API集成
PID块数据应使用AES-256对称算法(AES/ECB/PKCS7Padding)使用动态会话密钥进行加密。会话密钥又使用非对称算法(RSA/ECB/PKCS1Padding)使用2048位UIDAI公钥进行加密。
此元素的Skey值是加密的256位AES会话密钥的base-64编码值。
下面是我创建的代码:
/////////////////////
$ci = '20170922';
$method = 'AES-256-ECB';
$skey = openssl_encrypt (session_id(), $method ,$ci, true);
$pid_block = '<Pid ts="2016061512000000" ver="1.0"><Demo lang=""><Pi ms="E" mv="" name="Shivshankar Choudhury" lname="" lmv="" gender="" dob="" dobt="" age="" phone="" email="" /></Demo></Pid>';
$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 = '<Auth ac="public" sa="public" ver="1.6" txn="706bf70d" tid="public" uid="999999990019"><Uses pi="y" pa="n" pfa="n" bio="y" bt="FMR" otp="n" pin="n"/><Meta udc="UIDAI:SampleClient" fdc="NC" idc="NA" pip="127.0.0.1" lot="P" lov="560103"/><Skey ci="20131003" >'.$skey.'</Skey><Data type="X">'.$pid_encoded.'</Data><Hmac>'.$encoded_hmac_pid_block.'</Hmac></Auth>';
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);
答
这已经回答了在低于链接PHP。
How To integrate Aadhaar Card Authentication Api for Aadhaar number Verification in PHP?
如果你要使用Java,生成SKEY(32characters,256位),AES中,然后对其进行加密,您需要使用BouncyCastle的罐子。这是因为默认情况下java有128位(16个charcaters)限制的限制,然后对它进行编码。
你可以找到uidai开发人员门户网站的示例代码
的可能的复制[如何整合Aadhaar卡验证API在PHP Aadhaar号确认?(https://*.com/questions/31377015/how -to-整合-aadhaar卡认证-API换aadhaar号码验证) –