[英]How to scan new aadhaar card QR code and convert it into xml or object?
I am trying to convert the base10 encode data to base64 or xml or any readable format but no luck.我正在尝试将 base10 编码数据转换为 base64 或 xml 或任何可读格式,但没有成功。
The data is like after scanning the qr code:扫描二维码后的数据是这样的:
I have tried with old adhar qr scan which is giving xml format and I am parsing and getting data but in case of scanning new adhar qr code getting in above format, I also don't know which format it is.我已经尝试使用旧的 adhar 二维码扫描,它给出了 xml 格式,我正在解析和获取数据但是如果扫描新的 adhar 二维码以上述格式获取,我也不知道它是哪种格式。 I need to decode this data and get in proper format like xml or object format.
我需要解码这些数据并获得正确的格式,如 xml 或 object 格式。
This is my code:这是我的代码:
if (view == qr_check_box) {
Intent intent = new Intent(AbhaCard.this, ScanActivty.class);
startActivityForResult(intent, abhaQr);
}
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == abhaQr && resultCode == RESULT_OK) {
if (data != null) {
Barcode barcode = data.getParcelableExtra("barcode");
if (barcode != null && barcode.displayValue != null) {
try {
// Serializer(Simple library) is used for parsing xml data to object
Serializer serializer = new Persister();
String barcode_sting = barcode.displayValue;
scanResult.setText(barcode_sting);
Log.e("QR_code", barcode_sting);
try (InputStream stream = new ByteArrayInputStream(barcode_sting.getBytes())) {
// this serializer is user for converting xml to object(PrintLetterBarcodeData) in case of old adhar card scanning , so i want for new adhar cared qr code , how to convert.
barcodeData = serializer.read(PrintLetterBarcodeData.class, stream);
} catch (IOException e) {
e.printStackTrace();
}}**
// this is my PrintLetterBarcodeData class ised for parsing the xml to object // 这是我的 PrintLetterBarcodeData class 用于将 xml 解析为 object
@Root(name = "PrintLetterBarcodeData")
public class PrintLetterBarcodeData {
@Attribute(name = "uid")
private String uid;
@Attribute(name = "name")
private String name;
@Attribute(name = "gender")
private String gender;
@Attribute(name = "yob")
private String yob;
@Attribute(name = "co")
private String co;
@Attribute(name = "house")
private String house;
@Attribute(name = "street")
private String street;
@Attribute(name = "vtc")
private String vtc;
@Attribute(name = "po")
private String po;
@Attribute(name = "dist")
private String dist;
@Attribute(name = "subdist")
private String subdist;
@Attribute(name = "state")
private String state;
@Attribute(name = "pc")
private String pc;
@Attribute(name = "dob")
private String dob;}
This is python solution, If anyone knows python kindly convert in java send the code here.这是 python 的解决方案,如果有人知道 python 请转换成 java 将代码发送到这里。
import zlib
details = ["version","email_mobile_status","referenceid", "name", "dob",
"gender",
"careof", "district", "landmark", "house",
"location",
"pincode", "postoffice", "state", "street", "subdistrict", "vtc"]
delimeter = [-1]
data = {}
def initializeData(base10encodedData):
bytes_array = base10encodedData.to_bytes(5000, 'big').lstrip(b'\x00')
decompressed_array = zlib.decompress(bytes_array, 16 + zlib.MAX_WBITS)
if not decompressed_array[0:2].decode("ISO-8859-1") == 'V2':
details.pop(0)
for i in range(len(decompressed_array)):
if decompressed_array[i] == 255:
delimeter.append(i)
for i in range(len(details)):
data[details[i]] = decompressed_array[delimeter[i] + 1:delimeter[i +
1]].decode("ISO-8859-1")
data['adhaar_last_4_digit'] = data['referenceid'][0:4]
data['adhaar_last_digit'] = data['referenceid'][3]
data['mobile'] = False
if int(data['email_mobile_status']) == 3 or
int(data['email_mobile_status']) == 2:
data['mobile'] = True
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.