Skip to content

Instantly share code, notes, and snippets.

@VedantParanjape
Last active March 28, 2020 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VedantParanjape/080f5347622f459e8d9b934f346bd634 to your computer and use it in GitHub Desktop.
Save VedantParanjape/080f5347622f459e8d9b934f346bd634 to your computer and use it in GitHub Desktop.
Copies password from a file to the clipboard, clears the password after 10 seconds
import pyperclip
import hashlib
from daemonize import Daemonize
import time
import stdiomask
hash_const = # enter sha256 hash of your access passcode
def main():
passcode = stdiomask.getpass("enter passcode: ")
m = hashlib.sha256()
m.update(passcode.encode())
key = m.digest()
if key == hash_const:
print("\x1b[6;30;42m" + "authenticated" + "\x1b[0m")
with open('ExampleFile') as fp:
password = fp.read(1230)
pyperclip.copy(password)
fp.close()
return True
else:
print("\x1b[0;30;41m" + "wrong password" + "\x1b[0m")
return False
def clear_password():
time.sleep(10)
pyperclip.copy('******** password cleared')
if __name__ == "__main__":
if main():
deamon = Daemonize(app="gitpassword", pid="/tmp/gitpassword", action=clear_password)
deamon.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment