Update Picocrypt.py

This commit is contained in:
Evan Su 2021-04-11 20:08:43 -04:00 committed by GitHub
parent 3d394ad80b
commit a27937cd45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -524,6 +524,7 @@ startBtn["state"] = "disabled"
def cancel(): def cancel():
global working global working
working = False working = False
dummy.focus()
# Cancel button # Cancel button
cancelBtn = tkinter.ttk.Button( cancelBtn = tkinter.ttk.Button(
@ -572,7 +573,7 @@ creditsLabel["state"] = "disabled"
# Version # Version
versionString = tkinter.StringVar(tk) versionString = tkinter.StringVar(tk)
versionString.set("v1.12") versionString.set("v1.12.1")
version = tkinter.ttk.Label( version = tkinter.ttk.Label(
tk, tk,
textvariable=versionString textvariable=versionString
@ -1144,9 +1145,13 @@ def work():
if shouldErase: if shouldErase:
if onlyFolders: if onlyFolders:
for i in onlyFolders: for i in onlyFolders:
if not working:
break
secureWipe(i) secureWipe(i)
if onlyFiles: if onlyFiles:
for i in range(len(onlyFiles)): for i in range(len(onlyFiles)):
if not working:
break
statusString.set(strings[12]+f" ({i}/{len(onlyFiles)})") statusString.set(strings[12]+f" ({i}/{len(onlyFiles)})")
progress["value"] = i/len(onlyFiles) progress["value"] = i/len(onlyFiles)
secureWipe(onlyFiles[i]) secureWipe(onlyFiles[i])
@ -1158,8 +1163,18 @@ def work():
if allFiles or onlyFiles: if allFiles or onlyFiles:
remove(inputFile) remove(inputFile)
# Show appropriate notice if file corrupted or modified # Prevent Unicode nonsense on MacOS
arrow = "" if platform.system()=="Darwin" else "🡪" arrow = "" if platform.system()=="Darwin" else "🡪"
# If user hit 'Cancel' during secure wiping...
if not working:
fin.close()
fout.close()
resetUI()
statusString.set(f"Secure wipe canceled, but encryption was successful. (Output {arrow})")
else:
# Show appropriate notice if file corrupted or modified
if not kept: if not kept:
statusString.set(f"Completed. (Click here to show output {arrow})") statusString.set(f"Completed. (Click here to show output {arrow})")
# Show Reed-Solomon stats if it fixed corrupted bytes # Show Reed-Solomon stats if it fixed corrupted bytes
@ -1263,6 +1278,7 @@ def updateStats(total):
# Securely wipe file(s) via system internals # Securely wipe file(s) via system internals
def secureWipe(fin): def secureWipe(fin):
global working
statusString.set(strings[12]) statusString.set(strings[12])
progress["value"] = 100 progress["value"] = 100
# Check platform, erase accordingly # Check platform, erase accordingly
@ -1274,6 +1290,8 @@ def secureWipe(fin):
if dirname(i) not in paths: if dirname(i) not in paths:
paths.append(dirname(i)) paths.append(dirname(i))
for i in range(len(paths)): for i in range(len(paths)):
if not working:
return
statusString.set(strings[12]+f" ({i}/{len(paths)})") statusString.set(strings[12]+f" ({i}/{len(paths)})")
progress["value"] = 100*i/len(paths) progress["value"] = 100*i/len(paths)
system(f'cd "{paths[i]}" && "{rootDir}/sdelete64.exe" * -p 4 -nobanner') system(f'cd "{paths[i]}" && "{rootDir}/sdelete64.exe" * -p 4 -nobanner')