将凯撒密码加密/解密为文件文本

时间:2019-01-14 13:48:59

标签: python

我被困了好几天,无法在我的文本文件中找到一种加密/解密的方法。

我应该使用凯撒密码方法(但不能使用ROT 13)。无论做什么,我都无法正常工作。我发现所有方法都必须编写文本以对其进行加密,但是我希望将其保存到文本文件(section1.priv.txt)中。

有人可以帮助我吗?

class customer(object):
    def __init__(self,title, name, birth, country_of_birth, gender,    working_status, nationality,c_residence, tax_res,
        relation_ship_customer,phone_number,address,moved_in):
        self.title = title
        self.name = name
        self.birth = birth
        self.country_of_birth = country_of_birth
        self.gender = gender
        self.working_status = working_status
        self.nationality = nationality
        self.c_residence = c_residence
        self.tax_res = tax_res
        self.relation_ship_customer = relation_ship_customer
        self.phone_number = phone_number
        self.address = address
        self.moved_in = moved_in

    def customer_1_info(self):
      f=open("section1.priv.txt","a")
      f.write("CUSTOMER 1 INFO: "+"\n")
      f.write("Fullname: " + self.title + " " + self.name + "\n" + "Birth DD/MM/YY:v" + self.birth+"\n"
      + "Country and town of birth: "+self.country_of_birth
      +"\n"+ "Gender:" + self.gender +"\n"+ "Working Status: " + self.working_status+"\n" +"Nationality: "
      + self.nationality
      +"\n"+ "Country Residence: " + self.c_residence
      +"\n"+ "Tax Country Resident: " + self.tax_res + "\n"+ "Relationship to customer 2:"+self.relation_ship_customer+"\n")
      f.write("\n")
      f.write("CONTACT AND RESIDENTIAL DETAILS:"+"\n")
      f.write("Phone numbers(Mobile,home,work): "+self.phone_number+"\n"+"Address: "+self.address+"\n"
      +"Date moved in: "+self.moved_in+"\n")
      f.write("\n")
      f.close()

    def customer_2_info(self):
      f=open("section1.priv.txt","a")
      f.write("CUSTOMER 2 INFO: "+"\n")
      f.write("Fullname: " + self.title + " " + self.name + "\n" + "Birth DD/MM/YY: " + self.birth+"\n"
      + "Country and town of birth: "+self.country_of_birth
      +"\n"+ "Gender:" + self.gender +"\n"+ "Working Status: "+self.working_status +"\n"+ "Nationality: " + self.nationality +"\n"
      +"Country Residence: " + self.c_residence
      +"\n"+ "Tax Country Resident: " + self.tax_res +"\n"+"Relationship to customer 1: "+self.relation_ship_customer+"\n")
      f.write("\n")
      f.write("CONTACT AND RESIDENTIAL DETAILS:" + "\n")
      f.write("Phone numbers(Mobile,home,work): " + self.phone_number + "\n" + "Address: " + self.address + "\n"
      + "Date moved in: " + self.moved_in)
      f.write("\n")
      f.close()

p1 = customer(input("Mr, Mrs, Miss, Ms:"),
input("Fullname:"),
input("Birth DD/MM/YY:"),
input("Country and town of birth:"),
input("Female/male:"),
input("""Working status: Employed,Self Employed,Part Time,Unemployed(YY/MM), Not Working,Seeking Work, Retired, Student,Other(Explain)
Please WRITE status:"""),
input("Nationality: "),
input("Country Residence:"),
input("Tax Country Resident:"),
input("Relationship to customer 2:"),
input("Phone numbers(mobile,home,work:)"),
input("Full address(postcode,country):"),
input("Date moved in(MM/YYYY):"+"\n"))

p2 = customer(input("Mr, Mrs, Miss, Ms:"),
input("Fullname:"),
input("Birth DD/MM/YY:"),
input("Country and town of birth:"),
input("Female/male:"),
input("""Working status: Employed,Self Employed,
Part Time,Unemployed(YY/MM),Not Working,Seeking Work,   Retired,Student,Other(Explain)
Please write status:"""),
input("Nationality:"),
input("Country Residence:"),
input("Tax Country Resident:"),
input("Relationship to customer 1:"),
input("Phone numbers(mobile,home,work:"),
input("Full address(postcode,country:"),
input("Date moved in(MM/YYYY):"))

p1.customer_1_info()
p2.customer_1_info()  

0 个答案:

没有答案