def request_secret(secret_key, message, hidden=True):
"""
Request a secret from the user. Save the secrets to disk afterwards.
If there is already a secret for the key, return it.
:param secret_key: the key the input should be stored under in the secrets
:param message: the message to show to the user
:param hidden: hide the input (recommended for passwords and such)
:return the secret
"""
if secret_key in _secrets:
return _secrets[secret_key]
if hidden:
secret = getpass(message).strip()
else:
secret = input(message).strip()
_secrets[secret_key] = secret
save_secrets()
return secret
评论列表
文章目录