Is there an existing C# library that can be used to parse the information from a driver's license? I'm looking to parse the data directly from a swipe reader, so its a long string that needs to be broken down into it's components. I know that this is a big request, so I'm not interested in the validation of the numbers or even the license ID itself, I really just want to parse out the first and last name. I'm eventually interested in all 50 states but would like to see AZ and CA first.
-
4Don't know why people downvote this question. Remember, if you downvote you should tell why. – Ignacio Soler Garcia Aug 23 '11 at 18:50
-
1I'm not sure it's even possible to DO with a swipe reader. Looking at my NC driver's license, there's only a 2D barcode on the back; no mag-stripe. That being said, it's probably better if you can post a sample of the data you're looking at; it'll probably be a lot easier to find help with parsing a format than with info specific to driver's licenses. – Adam Robinson Aug 23 '11 at 18:54
-
4Because many of the people on SO that roam these forums all day long are egomaniacs and feel empowered by downvoting or voting to close questions. – Jeff Aug 23 '11 at 18:55
3 Answers
I realize this question was asked quite a while ago; but I actually don't agree with @FishBasketGordo that the answer is no; if you read this Wikipedia article you'll see a very clearly specified format that all U.S. driver's licenses (with magnetic stripes) supposedly adhere to, as specified in a standard by the AAMVA.
I personally have done some work on a JavaScript library to do exactly what you're asking (extract name, number, and in my case a few other bits of info) and have had success with the states I've been able to test. Obviously I haven't gotten my hands on licenses from all 50 states, though.
In any case, though I don't know of a library that you can leverage, I still wanted to weigh in on this question and suggest that this should be possible.
-
Dan, is your JS library available anywhere? I'm interested in it :) – Shannon Hicks May 16 '13 at 20:01
-
@ShannonHicks: The code belongs to my old employer now. I can ask them whether they'd be willing to open source it; but I highly doubt it. – Dan Tao May 16 '13 at 20:07
I haven't done an exhaustive search, but I have a little experience with this and I believe the answer is "No". Driver's licence formats vary by state and could potentially change often. However, if you're looking for just the first and last name, that should be fairly easy to figure out by trial and error. Most DL's aren't encrypted from what I've seen. Just setup your card reader through Hyperterminal or something similar and look at the output from you card swipes.
Edit: Please see @Dan Tao's answer as well as the comments for information on driver's license formats. There might even be a C# library for parsing AAMVA compliant license data now (there wasn't in 2011 to my knowledge), which was the original question, which is why I replied "No".

- 22,904
- 4
- 58
- 91
-
If there is a market, there is a library/solution, for a fee of course. Drivers license are pretty common and thus should have a market (even if it is a specialty device). – Aug 23 '11 at 19:02
-
I'm marking this as the preferred answer - I think the answer is "no" too and the trial-and-error method is what I'm left with. Having said that, it does seem like most of the delimiters are the same; "^" for tracks (I think) and "/" or "$" for firstname and lastname. Most of the ones tested so far have been on track 2 (I think) – Unknown Coder Aug 25 '11 at 16:45
-
1The AAMVA defines the standard for driver license magnetic stripes and barcodes. I found this immensely helpful in license data parsing: http://www.aamva.org/DL-ID-Card-Design-Standard/ – Nathan May 08 '14 at 13:57
I am not familiar with the driver's license strings which according to https://stackoverflow.com/users/783175/fishbasketgordo changes in various states, but it occurs to be that you have several choices.
- use regular expressions.
- use javascript (yes at the server) like suggested by the JInt package: http://jint.codeplex.com/discussions/240715 and then look for jQuery or node.js plugins
- use

- 1
- 1

- 568
- 4
- 9