Decoding the Aadhaar QR code consists of several steps outlined in Unique Identification Authority of India (UIDAI) in chapter 3.2:
The first few steps are:
- Convert the base10 value of Secure QR code into Big Integer.
- Convert the Big Integer into byte array.
- Decompress the byte array.
- Read the value of byte array from index 0 to till first delimiter value "255" and convert this byte array value into string with encoding "ISO-8859-1". We will get the Email_mobile_present_bit_indicator_value as 0, 1, 2 or 3.
Once you have the decompressed array, you can simply search for the first element in the array containing -1, which is how the byte value 255 looks in Java as Java uses signed integer for bytes. The bytes before the -1 can be converted to a string.
These two steps are then repeating several times with the remaining data in the array to extract further values.
Extracting the photo and the signature are slightly different as they are not strings but binary data. Again, the steps are described in the referenced document.