You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.2 KiB

  1. from random import randrange, randint
  2. from datetime import date, timedelta
  3. def random_date(start, end):
  4. delta = end - start
  5. return start + timedelta(seconds=randrange(delta.total_seconds()))
  6. def generate_identification_id(start_date, end_date):
  7. birthday = random_date(start_date, end_date)
  8. year = str(birthday.year)[2:]
  9. month = str(birthday.month).zfill(2)
  10. day = str(birthday.day).zfill(2)
  11. gender = str(randint(1, 998)).zfill(3)
  12. millenium_baby = birthday.year > 2000
  13. main_number = year + month + day + gender
  14. control_number = '2' + main_number if millenium_baby else main_number
  15. control_number = 97 - int(control_number) % 97
  16. control_number = str(control_number).zfill(2)
  17. return main_number + control_number
  18. def identification_id_to_gender(identification_id):
  19. if identification_id and len(identification_id) == 11:
  20. gender = identification_id[6:9]
  21. return int(gender) % 2
  22. INDENTITY_ID = generate_identification_id(date(1920, 1, 1), date(1995, 12, 31))
  23. GENDER = identification_id_to_gender(INDENTITY_ID)
  24. print('Rijksregisternummer: ' + INDENTITY_ID)
  25. print('Geslacht: ' + ('Man' if GENDER else 'Vrouw'))