passwords_opti2.py

Created by elnix91

Created on September 28, 2025

1.82 KB

a try to create encrypted password manager this is the last version i guess


CHARLIST="""abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:;"'%[]{}_,→()*/+-?!&^|#"""
PASSWORDS=[]

def analyse(key):
  if len(key)<1:return 0
  for i in range(len(str(key))):
    if not key[i] in CHARLIST:return 0
  return 1

def encrypt(key,MASTER):
  crypted=""
  if analyse(key) and analyse(MASTER):
    for i in range(len(key)):
      crypted+=CHARLIST[(CHARLIST.index(key[i])+CHARLIST.index(MASTER[i%len(MASTER)]))%len(CHARLIST)]
    return crypted

def decrypt(key,MASTER):
  decrypted=""
  if analyse(key) and analyse(MASTER):
    for i in range(len(key)):
      decrypted+=CHARLIST[(CHARLIST.index(key[i])-CHARLIST.index(MASTER[i%len(MASTER)]))%len(CHARLIST)]
    return decrypted

def addPassword(key="",MASTER=""):
  if key=="":key=input("Enter new password:    ")
  if MASTER=="":MASTER=input("Enter master password: ")
  if encrypt(key,MASTER)not in PASSWORDS:
    PASSWORDS.append(encrypt(key,MASTER))

def removePassword(key="",MASTER=""):
  if key=="":key=input("Enter the password you want to remove:\n")
  if MASTER=="":MASTER=input("Enter master password: ")
  if encrypt(key,MASTER)in PASSWORDS:
    PASSWORDS.remove(encrypt(key,MASTER))

def readPasswords(MASTER=""):
  if MASTER=="":MASTER=input("Enter master password:")
  for i in range(len(PASSWORDS)):
    print(PASSWORDS[i]+""+decrypt(PASSWORDS[i],MASTER))

def syncr(echo=1):
  try:f=open("mdpsave.sav","r")
  except NameError:
    if echo:print("Error: make sure your on Omega\n       to use files functions")
  else:
    cp=f.read(2**20)
    while " "in cp:
      print(cp)
      if cp[:cp.index(" ")]not in PASSWORDS:
        PASSWORDS.append(cp[:cp.index(" ")])
      cp=cp[cp.index(" ")+1:]
    f=open("mdpsave.sav","w")
    f.truncate(0)
    if len(PASSWORDS)>0:
      for i in range(len(PASSWORDS)):
        f.write(PASSWORDS[i]+" ")

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.