Last active
June 30, 2021 22:38
-
-
Save tubaman/a2bcbc07a69ea2c4a7353291760755b4 to your computer and use it in GitHub Desktop.
Python module to get password data from password-store.org(pass)
This file contains 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
"""Python module to get password data from password-store.org(pass) | |
ex: | |
from pwstore import pwstore | |
password, data = pwstore("example.org") | |
username = data['Username'] | |
""" | |
import re | |
from subprocess import check_output | |
def pwstore(name): | |
out = check_output(['pass', name]) | |
lines = out.decode('utf-8').splitlines() | |
pword = lines[0] | |
data = dict([re.split(r":\s*", line, 1) for line in lines[1:]]) | |
return pword, data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment