Update passwordalchemy.py

main
witchdocsec 2024-05-27 13:45:22 +01:00 committed by GitHub
parent 31b523e4cf
commit b91e347279
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 3 deletions

View File

@ -30,13 +30,15 @@ class mainfuncs:
if args.oldprivatekey:
creds=lib.db.fetchall()
#if creds are present
if creds:
try:
for cred in creds:
with open(args.privatekey) as pemfile:
privkey=rsa.PrivateKey._load_pkcs1_pem(pemfile.read())
pcred=rsa.decrypt(base64.b64decode(cred.ccred),oldprivatekey).decode("utf-8")
ccred=base64.b64encode(rsa.encrypt(pcred.encode("utf-8"),pubkey)).decode("utf-8")
lib.db.update(cred.domain,ccred)
lib.db.update(cred.domain,ccred)
except:
pass
#fetch a credential
@staticmethod
@ -80,4 +82,4 @@ if __name__ == "__main__":
if args.command:
command=getattr(mainfuncs,args.command)
#execute
command(args)
command(args)