Posted by notme on Sat 24 May 12:02
report abuse | download | new post
- #include <iostream>
- #include <string>
- using namespace std;
- char generateChecksum(string s) {
- int checks = 0;
- for (int i=0; i <s.length(); i++) {
- int nr = (s[i] - 0x30);
- if (i % 3 == 0) checks += (7 * nr);
- if (i % 3 == 1) checks += (3 * nr);
- if (i % 3 == 2) checks += nr;
- }
- char ret = (checks % 10) + 0x30;
- return ret;
- }
- int main()
- {
- string base = "7881738905";
- string birth = "";
- string expire = "";
- cout << "Geburts (yymmdd):";
- cin >> birth;
- cout << endl;
- cout << "Ablauf (yymmdd):";
- cin >> expire;
- cout << endl;
- string subfinal = base + birth + generateChecksum(birth) + expire + generateChecksum(expire);
- string final = base + "D << " + birth + generateChecksum(birth) + " < " + expire + generateChecksum(expire) + " <<<<<<< " + generateChecksum(subfinal);
- cout << "Personalausweisnummer:\n" << final;
- }
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.