<-- Projects  

Some time ago, in the year 2003, the Internet was yet again threatend by the Enemies of Freedom. Some simple minded people tried to establish a age verification system based on the german identity card number. The identity card number is unique and inculdes the date of birth and a simple checksum.

The amazingly stupid thing about building an age verification system based on this was that the algorithm behind this identity card number was known to the public since this type of identity card was introduced. It was even published by the government.

Now you may ask why such childish attempts in narrowing the freedom of the internet even bothered me. Well, because at this time my colleagues and me were all big counterstike gamers (Version 0.3 till 1.0 btw, we switched to Battlefield 1942 afterwards). And the main german CS site, www.counterstike.de was, for a short periode, "protected" by such a age verification system. Although our whole "clan" *cough* was older than 18 we, as freedom loving citizens, would never give our life long personal unique id to a private company.

So it was up to me to fight this evil and create the:
 

MIF Identity Card Number generator
 
Screenshot of the MIF Identity Card Number generator

After a bit internet research i found a verbal description of the algorithm. There where no code samples like those which can be found everywhere around nowadays, so i implemented the algorithm from scratch in my favourite RAD language, VB6.

So here is the original description i found:

Die ersten 4 Ziffern der Seriennummer stellen die Behoerdenkennzahl der Personalausweisbehoerde dar, 
danach kommen 5 Ziffern, die eine einfache Zaehlnummer sind. Die zehnte Ziffer ist die Pruefsumme.

Die beiden letzten Zeilen sind Maschinenlesbar. Die erste Zeile ist folgendermaßen aufgebaut:
IDD steht für "Identitaetskarte der Bundesrepublik Deutschland", danach folgt der Nachname, der erste 
Vorname und u.U. ein Doktortitel.

Die zweite Zeile ist komplizierter und besteht, wie unten grafisch Dargestellt, aus Seriennummer, 
Geburtsdatum, Ablaufdatum und Prüfsummen.

Die Prüfsummen werden folgendermaßen gebildet:

1) Die erste  Ziffer wird mit 7 multipliziert,
   die zweite Ziffer wird mit 3 multipliziert,
   die dritte Ziffer wird mit 1 multipliziert, usw.

2) Die so erhaltenen Zahlen werden aufsummiert.

3) Die Prüfsumme ist dann diese Summe modulo 10
   (die Einerstelle der Summe).

Composition of the id card number

With this information the coding was pretty straightforward:

Private Sub Command1_Click()

Zahl1 = (900000000 - 100000000 + 1) * Rnd + 100000000

Eins = Zahl1 & Pruefsumme(Zahl1)
Zwei = DatumRichten(Text4.Text) & Pruefsumme(DatumRichten(Text4.Text))
Drei = DatumRichten(Text5.Text) & Pruefsumme(DatumRichten(Text5.Text))
Vier = Pruefsumme(Eins & Zwei & Drei)
Text7.Text = Eins & "D<<" & Zwei & "<" & Drei & "<<<<<<<" & Vier
End Sub

Private Function DatumRichten(Datum)
Dim neuesDatum As String
neuesDatum = Right(Datum, 2) & Mid(Datum, 4, 2) & Left(Datum, 2)
DatumRichten = neuesDatum
End Function

Private Function Pruefsumme(intZahl)
On Error Resume Next
Dim i As Integer
Dim intZiffern() As Integer
ReDim intZiffern(1 To Len(intZahl))
Dim intSumme As Integer
Dim intPruefziffer As Integer

For i = 1 To Len(intZahl)
    intZiffern(i) = Mid(intZahl, i, 1)

    Select Case i
        Case 1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 38
            intZiffern(i) = intZiffern(i) * 7
        
        Case 2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41
            intZiffern(i) = intZiffern(i) * 3
    End Select
    
    intSumme = intSumme + intZiffern(i)
Next i
intPruefziffer = Right(intSumme, 1)
Pruefsumme = intPruefziffer
End Function

Only the intresting parts are shown above. The whole program, including the stunning artwork and music :-) can be downloaded here.