|
| 1 | +import os |
| 2 | + |
| 3 | +from tkinter import * |
| 4 | +import tkinter.messagebox as mb |
| 5 | + |
| 6 | +os.chdir(r'C:\\ProgramData') |
| 7 | + |
| 8 | +if os.path.isdir("PRIVATE"): |
| 9 | + pass |
| 10 | +else: |
| 11 | + os.mkdir('PRIVATE') |
| 12 | +os.chdir('PRIVATE') |
| 13 | + |
| 14 | +class mypassword(): |
| 15 | + def __init__(self): |
| 16 | + self.root = Tk() |
| 17 | + self.root.title("Passwordsaver by king") |
| 18 | + self.root.geometry("600x700") |
| 19 | + |
| 20 | + self.mainframe=Frame(self.root) |
| 21 | + self.fill_1 = Label(self.mainframe, text=" ", width=10).grid(row=1 ,column=0) |
| 22 | + self.fill_p = Label(self.mainframe, text="Password ", font=" arial 13",width=10,bg="red").grid(row=2 ,column=1) |
| 23 | + |
| 24 | + self.p_val = StringVar() |
| 25 | + self.p_show="*" |
| 26 | + self.p_value = Entry(self.mainframe, textvariable=self.p_val, font="arial 8",show=self.p_show) |
| 27 | + self.p_value.grid(row=4,column=1) |
| 28 | + |
| 29 | + self.show_pasword = Button(self.mainframe, text="show",font= "arial 8", width=6,command=self.normal).grid(row=4 ,column=3) |
| 30 | + self.enter_p = Button(self.mainframe, text="enter", font=" arial 8",width=6,command=self.king).grid(row=5 ,column=1) |
| 31 | + |
| 32 | + self.mainframe.pack() |
| 33 | + self.root.mainloop() |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + def king(self): |
| 38 | + |
| 39 | + if self.p_val.get()=="KING": |
| 40 | + self.mainframe.destroy() |
| 41 | + self.fillchoice=Label(self.root,text="Enter choice ",font=" arial 20",).place(x=100,y=15) |
| 42 | + self.encryption=Label(self.root,text="1.Encryption ",font=" arial 18", bg="blue").place(x=5,y=50) |
| 43 | + self.decryption=Label(self.root,text="2.Decryption ",font=" arial 18", bg="yellow").place(x=200,y=50) |
| 44 | + self.delete=Label(self.root,text="3.Delete ",font=" arial 18" ,bg="violet").place(x=5,y=120) |
| 45 | + self.listdir=Label(self.root,text="4.List ",font=" arial 18", bg="green").place(x=200,y=120) |
| 46 | + self.val=StringVar() |
| 47 | + self.value=Entry(self.root,textvariable=self.val,font="arial 15").place(x=5,y=160) |
| 48 | + self.enter=Button(self.root,text="enter",font=" arial 12",command=self.run, bg="red").place(x=190,y=160) |
| 49 | + else: |
| 50 | + self.p_val.set("") |
| 51 | + mb.showwarning("Waring","Incorrect Password") |
| 52 | + |
| 53 | + |
| 54 | + #process |
| 55 | + def run(self): |
| 56 | + if self.val.get()=="1": |
| 57 | + os.chdir(r'C:\\ProgramData\\PRIVATE') |
| 58 | + try: |
| 59 | + self.enframe.destroy() |
| 60 | + self.display.destroy() |
| 61 | + self.delete_frame.destroy() |
| 62 | + self.display_inner.destroy() |
| 63 | + except: |
| 64 | + pass |
| 65 | + self.enframe=Frame(self.root ) |
| 66 | + self.filename = StringVar() |
| 67 | + Label(self.enframe, text="Filename ", font=" arial 8").pack(side=TOP, anchor=NW) |
| 68 | + self.filenametext = Entry(self.enframe, textvariable=self.filename, font="arial 8").pack(side=TOP, anchor=NW) |
| 69 | + # get username |
| 70 | + self.username = StringVar() |
| 71 | + Label(self.enframe, text="Enter Username ", font=" arial 8").pack(side=TOP, anchor=NW) |
| 72 | + self.usernametext = Entry(self.enframe, textvariable=self.username, font="arial 10").pack(side=TOP, anchor=NW) |
| 73 | + |
| 74 | + #get password |
| 75 | + self.password = StringVar() |
| 76 | + Label(self.enframe, text="Enter Password ", font=" arial 8").pack(side=TOP, anchor=NW) |
| 77 | + self.passwordtext = Entry(self.enframe, textvariable=self.password, font="arial 8",show="*" |
| 78 | + ).pack(side=TOP, anchor=NW) |
| 79 | + self.show_pasword = Button(self.enframe, text="show", font="arial 8", |
| 80 | + command=self.normal).pack(side=TOP, anchor=NW) |
| 81 | + |
| 82 | + # buttons |
| 83 | + self.enter = Button(self.enframe, text="save", font=" arial 8", |
| 84 | + command=self.save).pack(side=TOP, anchor=NW) |
| 85 | + |
| 86 | + self.clear = Button(self.enframe, text="clear", font=" arial 8", |
| 87 | + command=self.clear).pack(side=TOP, anchor=NW) |
| 88 | + self.enframe.place(x=5,y=230) |
| 89 | + |
| 90 | + |
| 91 | + elif self.val.get()=="2": |
| 92 | + os.chdir(r'C:\\ProgramData\\PRIVATE') |
| 93 | + try: |
| 94 | + self.enframe.destroy() |
| 95 | + self.display.destroy() |
| 96 | + self.delete_frame.destroy() |
| 97 | + self.display_inner.destroy() |
| 98 | + |
| 99 | + except: |
| 100 | + pass |
| 101 | + |
| 102 | + self.display = Frame(self.root) |
| 103 | + self.filename = StringVar() |
| 104 | + Label(self.display, text="Enter Filename ", font=" arial 9").pack(side=TOP, anchor=NW) |
| 105 | + self.filenametext= Entry(self.display, textvariable=self.filename, font="arial 9",).pack(side=TOP, |
| 106 | + anchor=NW) |
| 107 | + self.enter = Button(self.display, text="show", font=" arial 9", |
| 108 | + command=self.show).pack(side=TOP, anchor=NW) |
| 109 | + self.username = StringVar() |
| 110 | + self.password = StringVar() |
| 111 | + Label(self.display, text=" Username ", font=" arial 10").pack(side=TOP, anchor=NW) |
| 112 | + self.usernametext = Entry(self.display, textvariable=self.username, font="arial 10",).pack(side=TOP,anchor=NW) |
| 113 | + |
| 114 | + |
| 115 | + Label(self.display, text=" Password ", font=" arial 10").pack(side=TOP, anchor=NW) |
| 116 | + self.passwordtext = Entry(self.display, textvariable=self.password, font="arial 10",).pack(side=TOP,anchor=NW) |
| 117 | + self.display.place(x=5,y=230) |
| 118 | + |
| 119 | + |
| 120 | + elif self.val.get() == "3": |
| 121 | + os.chdir(r'C:\\ProgramData\\PRIVATE') |
| 122 | + try: |
| 123 | + self.enframe.destroy() |
| 124 | + self.display.destroy() |
| 125 | + self.delete_frame.destroy() |
| 126 | + # self.display_inner.destroy() |
| 127 | + except: |
| 128 | + pass |
| 129 | + self.delete_frame = Frame(self.root) |
| 130 | + self.filename = StringVar() |
| 131 | + Label(self.delete_frame, text="Enter Filename ", font=" arial 9").pack(side=TOP, anchor=NW) |
| 132 | + self.filenametext = Entry(self.delete_frame, textvariable=self.filename, font="arial 9", ).pack( |
| 133 | + side=TOP, |
| 134 | + anchor=NW) |
| 135 | + self.delete_data = Button(self.delete_frame, text="delete", font=" arial 9" , |
| 136 | + command=self.remove).pack(side=TOP, anchor=NW) |
| 137 | + |
| 138 | + |
| 139 | + self.delete_frame.place(x=5,y=230) |
| 140 | + elif self.val.get()=="4": |
| 141 | + os.chdir(r'C:\\ProgramData\\PRIVATE') |
| 142 | + try: |
| 143 | + |
| 144 | + self.showlist.destroy() |
| 145 | + except: |
| 146 | + pass |
| 147 | + self.showlist= Frame(self.root) |
| 148 | + self.refreshbtn = Button(self.showlist, text="refresh", font=" arial 8", |
| 149 | + command=self.refresh).pack(side=TOP, ) |
| 150 | + self.closebtn = Button(self.showlist, text="close", font=" arial 8", |
| 151 | + command=self.close).pack(side=TOP,) |
| 152 | + self.b = Scrollbar(self.showlist) |
| 153 | + self.b.pack(side=RIGHT,fill=Y,anchor=N) |
| 154 | + |
| 155 | + self.l=Listbox(self.showlist,yscrollcommand=self.b.set,font="10",height=5,) |
| 156 | + |
| 157 | + for i in os.listdir(): |
| 158 | + |
| 159 | + self.one="" |
| 160 | + for j in i: |
| 161 | + self.letter=ord(j) -150 |
| 162 | + |
| 163 | + self.one+=chr(self.letter) |
| 164 | + self.l.insert(END,f"{self.one}") |
| 165 | + |
| 166 | + |
| 167 | + |
| 168 | + self.l.pack(side=LEFT,fill=Y) |
| 169 | + self.b.config(command=self.l.yview) |
| 170 | + |
| 171 | + self.showlist.config(background="red") |
| 172 | + self.showlist.place(x=350,y=200) |
| 173 | + |
| 174 | + |
| 175 | + |
| 176 | + else: |
| 177 | + self.val.set("") |
| 178 | + |
| 179 | + |
| 180 | + def save(self): |
| 181 | + |
| 182 | + self.username_1 = "" |
| 183 | + self.password_1 = "" |
| 184 | + self.new = "" |
| 185 | + |
| 186 | + for i in self.filename.get(): |
| 187 | + self.one = ord(i) +150 |
| 188 | + self.new += chr(self.one) |
| 189 | + |
| 190 | + for i in self.password.get(): |
| 191 | + self.num = ord(i) + 50 |
| 192 | + self.password_1 += chr(self.num) |
| 193 | + for i in self.username.get(): |
| 194 | + self.num = ord(i)+70 |
| 195 | + self.username_1 += chr(self.num) |
| 196 | + |
| 197 | + if os.path.isdir(self.new): |
| 198 | + mb.showinfo("exists","already exsits") |
| 199 | + else: |
| 200 | + |
| 201 | + os.makedirs(self.new) |
| 202 | + os.chdir((self.new)) |
| 203 | + os.makedirs(str(1) + self.username_1) |
| 204 | + os.makedirs(str(2) + self.password_1) |
| 205 | + os.chdir(r'C:\\ProgramData') |
| 206 | + |
| 207 | + |
| 208 | + def show(self): |
| 209 | + try: |
| 210 | + self.display_inner.destroy() |
| 211 | + except: |
| 212 | + pass |
| 213 | + |
| 214 | + os.chdir(r'C:\\ProgramData\\PRIVATE') |
| 215 | + # print(os.getcwd()) |
| 216 | + self.new="" |
| 217 | + # print(self.filename.get()) |
| 218 | + for i in self.filename.get(): |
| 219 | + self.one = ord(i) +150 |
| 220 | + self.new +=chr(self.one) |
| 221 | + |
| 222 | + try: |
| 223 | + os.chdir(self.new) |
| 224 | + |
| 225 | + self.dir=os.listdir() |
| 226 | + self.username_1 = "" |
| 227 | + self.password_1 = "" |
| 228 | + for i in self.dir[0][1:]: |
| 229 | + user = (ord(i)-70) |
| 230 | + self.username_1+=chr(user) |
| 231 | + for i in self.dir[1][1:]: |
| 232 | + # ord(i) + 34*ord(i) + 50 |
| 233 | + |
| 234 | + pas=(ord(i)-50) |
| 235 | + self.password_1+=chr(pas) |
| 236 | + |
| 237 | + |
| 238 | + |
| 239 | + |
| 240 | + |
| 241 | + |
| 242 | + self.password.set(self.password_1) |
| 243 | + self.username.set(self.username_1) |
| 244 | + |
| 245 | + |
| 246 | + |
| 247 | + |
| 248 | + |
| 249 | + except: |
| 250 | + self.filename.set("") |
| 251 | + mb.showerror("error","invalid filename") |
| 252 | + |
| 253 | + def clear(self): |
| 254 | + try: |
| 255 | + self.filename.set("") |
| 256 | + self.username.set("") |
| 257 | + self.password.set("") |
| 258 | + except: |
| 259 | + pass |
| 260 | + os.chdir(r'C:\\ProgramData\\PRIVATE') |
| 261 | + |
| 262 | + def clear_data(self): |
| 263 | + self.filename.set("") |
| 264 | + try: |
| 265 | + self.display_inner.destroy() |
| 266 | + except: |
| 267 | + pass |
| 268 | + os.chdir(r'C:\\ProgramData\\PRIVATE') |
| 269 | + def remove(self): |
| 270 | + try: |
| 271 | + self.new = "" |
| 272 | + for i in self.filename.get(): |
| 273 | + self.one = ord(i) + 150 |
| 274 | + self.new += chr(self.one) |
| 275 | + os.chdir(r'C:\\ProgramData\\PRIVATE') |
| 276 | + os.chdir(self.new) |
| 277 | + for i in os.listdir(): |
| 278 | + os.rmdir(i) |
| 279 | + os.chdir(r'C:\\ProgramData\\PRIVATE') |
| 280 | + os.rmdir(self.new) |
| 281 | + mb.showinfo("sucess","Sucessfully Deleted") |
| 282 | + except: |
| 283 | + mb.showerror("error","file not exsist") |
| 284 | + def change(self): |
| 285 | + pass |
| 286 | + def normal(self): |
| 287 | + try: |
| 288 | + mb.showinfo("password", self.password.get()) |
| 289 | + except: |
| 290 | + mb.showinfo("password",self.p_val.get()) |
| 291 | + |
| 292 | + |
| 293 | + |
| 294 | + def refresh(self): |
| 295 | + self.l.delete(0,END) |
| 296 | + os.chdir(r'C:\\ProgramData\\PRIVATE') |
| 297 | + for i in os.listdir(): |
| 298 | + |
| 299 | + self.one = "" |
| 300 | + for j in i: |
| 301 | + self.letter = ord(j) - 150 |
| 302 | + # self.letter=ord(j) +150 -100 - 200 - 100 + 150 |
| 303 | + self.one += chr(self.letter) |
| 304 | + self.l.insert(END, f"{self.one}") |
| 305 | + def close(self): |
| 306 | + self.p_val.set("") |
| 307 | + self.showlist.destroy() |
| 308 | + |
| 309 | + |
| 310 | + |
| 311 | +mypassword() |
0 commit comments