Last active
March 28, 2020 11:16
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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