"""LifeTel Telecom is the latest entrant in the highly competitive Telecom market of Singapore. It issues SIM to the
verified users. Till now verification was manual through the photocopy of approved id card document. However
government has recently introduced Social ID called Reference ID which is mapped to fingerprint of user. LifeTel
should now verify user against the fingerprint and Reference ID """
import re  # importing for checking regular expression
import base64  # importing for encoding and decoding string in python
x = True
ref_id = input("Enter the Reference ID:- ")
while x:
    if len(ref_id) != 12:  # This will check the length of reference id it should be 12 digit.
        # print(x)
        print("Not Valid| Length should be 12 Character")
        break
    elif not re.search("[A-Z]", ref_id):  # To check that reference id should contain any Capital Alphabet
        print("Not valid| Reference ID  should contain at least one  Letter")
        break
    elif not re.search("[$#@]", ref_id):  # enhancement in code to check if it contain any special character
        print("Not valid| Reference ID should contain at least once character from $#@")
        break
    elif not re.search("[0-9]", ref_id):
        print("Not valid| Reference ID should contain at least once) character 0-9")
        break
    else:
        print("Enter Reference ID is Correct")
        ref_id_en = base64.b64encode(ref_id.encode())  # encoding the reference id
        print("Reference ID is correct and now encrypted:-", ref_id_en)  # Printing the Encrypted reference ID
        ans1 = int(input("Enter the date of birth present in your record in format DDMMYY to decrypt the reference:-"))
        if ans1 == 170490:  # assuming the date of birth is pre register in database
            ref_id_de = base64.b64decode(ref_id_en.decode("ascii"))
            ref_id_final=ref_id_de.decode("ascii")
            print(ref_id_final)
        else:
            print ("Enter DOB is incorrect")
            break