The barcode on the back of a South African drivers licence contains 720 bytes encoded into a PDF417 barcode format. The first 4 bytes contains a version number that should be used to decide which of the encryption keys to use. All currently valid licences use version 2 for decryption.
Version bytes | Version |
---|---|
01 e1 02 45 |
Version 1 |
01 9b 09 45 |
Version 2 |
Following the version number are 2 bytes containing zeros, i.e. 00 00
. The remaining 714 bytes contains the encrypted drivers licence data.
The data should be divided into 6 blocks. The first 5 blocks should each be 128 bytes, and the remaining block should be 74 bytes. Each of the licence data blocks should be decrypted using RSA ENCRYPT with the specific licence version public key.
The licence holder details are contained within the first block.
Version 1 - 128 bytes
-----BEGIN RSA PUBLIC KEY-----
MIGXAoGBAP7S4cJ+M2MxbncxenpSxUmBOVGGvkl0dgxyUY1j4FRKSNCIszLFsMNw
x2XWXZg8H53gpCsxDMwHrncL0rYdak3M6sdXaJvcv2CEePrzEvYIfMSWw3Ys9cRl
HK7No0mfrn7bfrQOPhjrMEFw6R7VsVaqzm9DLW7KbMNYUd6MZ49nAhEAu3l//ex/
nkLJ1vebE3BZ2w==
-----END RSA PUBLIC KEY-----
Version 1 - 74 bytes
-----BEGIN RSA PUBLIC KEY-----
MGACSwD/POxrX0Djw2YUUbn8+u866wbcIynA5vTczJJ5cmcWzhW74F7tLFcRvPj1
tsj3J221xDv6owQNwBqxS5xNFvccDOXqlT8MdUxrFwIRANsFuoItmswz+rfY9Cf5
zmU=
-----END RSA PUBLIC KEY-----
Version 2 - 128 bytes
-----BEGIN RSA PUBLIC KEY-----
MIGWAoGBAMqfGO9sPz+kxaRh/qVKsZQGul7NdG1gonSS3KPXTjtcHTFfexA4MkGA
mwKeu9XeTRFgMMxX99WmyaFvNzuxSlCFI/foCkx0TZCFZjpKFHLXryxWrkG1Bl9+
+gKTvTJ4rWk1RvnxYhm3n/Rxo2NoJM/822Oo7YBZ5rmk8NuJU4HLAhAYcJLaZFTO
sYU+aRX4RmoF
-----END RSA PUBLIC KEY-----
Version 2 - 74 bytes
-----BEGIN RSA PUBLIC KEY-----
MF8CSwC0BKDfEdHKz/GhoEjU1XP5U6YsWD10klknVhpteh4rFAQlJq9wtVBUc5Dq
bsdI0w/bga20kODDahmGtASy9fae9dobZj5ZUJEw5wIQMJz+2XGf4qXiDJu0R2U4
Kw==
-----END RSA PUBLIC KEY-----
Refer to this repository for interpretation information: https://github.com/ugommirikwe/sa-license-decoder
// Byte array contianing raw licence bytes from barcode
var encryptedLicenceBytes = ...;
// Decrypt and decode licence fields
var driversLicenceService = new DriversLicenceService();
var decryptedLicenceBytes = driversLicenceService.DecryptLicence(encryptedLicenceBytes);
var licence = driversLicenceService.DecodeLicence(decryptedLicenceBytes);
// Read fields from licence object
var surname = licence.Surname;
var initials = licence.Initials;
Raw barcode data (base64)
Licence holder: JH Schoeman
AZsJRQAAZxPEXcrzenVzwtrtm630N042KTifimvzxlEEOEQH9m8yM9S6uDMFLIndFcyA+TBpH/j8x3vwSU6kCLXsBGWpuIWAyVxGzCE0n8oDoQuVd4y9lnLFPRUOSq58v5thva3NPGnxEDMjbS4SJ/afSdtAGoWnAhpUfGFrcDgzcjjTfRCGuzxzDHN/qsFkuunNrwJzkE+odXmQeHeWYPh/vwoor1Nzmsh8OXWBAP2bzDvtyHFsNSErf5Ea3WTEMoG9GOsS8bx/ASSfFOz35ujtLixm8y8HFq7yG1t/69iJRXYyyqqHi20lPV1PA43lZd9UspyLPdh3FHgMDowCexV32TdfdsLuhovydg4n3SrEsWEawvBpWITS64CwDCzVJQWj86z1iiMGpHFyUZ5n3Txawebkn4U1/sk+jZsyLvm6LMWwku3kpF+gunwBRGPoYNb68QXr7Juu5qMlXDQ6DMmXSzeafXCzRphmiFE+8iST+00a6EQ81yGCf37skziR4H9HHMLhl8EeqCIz0yxmb3CALa5x0rr87CVQ90WNQMI/DA89lFIlPZrmx5vX2Vkvp0TBw8QLlF9IaTyhtEdnWYfqUdYxvtmcY4ZbJahEb/IlmkVPNwdkbCeBLxdUEMkwyCxgwxJnVWUMXRN9zRWyhsMtzMuzB01mcpkUTfRMxOsk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AAA
Decrypted Licence (base64)
Licence holder: J Sanders
Am0WAwAyARaCWkLh4eFTQU5ERVJT4ErhWkHgWkHgMOHh4TYyMzQ1NjAwMDFBQuA4NjA5MTM1MTM5MDEyAiAHAhmqoQoBGYYJEyASERQgFxIUAVdJBAD6AMhDLihAAChCNFWnQrzo0jDnNeVd2987O9NM9v45zkHm/ll7Ivb5cBQx7vfrFr3e975/m97of/HDQKGCh/LRixwt8OqE5KhYXoNDmoVPDQKFWdbMIXtUo8+40zll0RmpShJw785Ys/luDajQ1gRRksEkr7FjiKHRMO4wpyFBGMJfagh7iuNxHOEMJFrGOBpRg5UETHrDTx0mx9RmWuHQjFA+Naa7abq64z0qL5B3ktR5oFuN4rtWXoZeql6MiPthbIY+vGEUN5mPczaChm0UvGwwkQckiCBP+LSAAVexEcEgAKywW4F+62PhksQeG6Zx/0fCjSQUBWD4fEwVwSnz5ARYJAVimcsOERK2EkQ0kXYSqR2NGSxZ9JY1ADb8Y2aC1hQPh/F/NXq+j/IVV3ratkIa1ETAaPu91/FhMgl1MdUWp5yn8UVVm+wFiWW1IC/UsvkUOkKHhSYCaMqt5loAOXGqumWXwtoOK4QcqHboj8RwAqatEPFrOGDu9ChjRI9HpjPpgvTsB3VGApj8Q8RXRPC8zi097mSBVqhNcGcO2vSTKjjIPC5yG+ISRwvFBBnEW9tarAR3lZ98IAMIQgu0VTRca4lsqeIB8xjXXuw1l24bRDiPYi5JEwAlWO09CP+G+6jYdgVLBYskCWGukFDX2g2NLBGjvYB47rCucJ8Yhgjdik1EAgNiKFN3KCCS6qCixBMkBqrbd0FnPWnX3eYFjOWqLbVoEAUARFpF1RRFEBRZS4YgoqogABY7UAEAFFAFVVUBBEVAVVQQAAAAAAAAAAAAAAAA
https://www.b4x.com/android/forum/threads/rsa-encryption-decryption.89436/
https://stackoverflow.com/questions/17549231/decode-south-african-za-drivers-license
https://github.com/ugommirikwe/sa-license-decoder
https://www.b4x.com/android/forum/threads/solved-need-assistance-with-rsa-decryption.118756/