从 aznashwan/py-securestring 派生的 Window 的 Securestring 的 Python 实现
项目描述
此软件包可用作在 Windows 10 计算机中安全保存密码的一种方式。它使用 PowerShell 的SecureString
函数和对象。
安装
您只需通过以下方式从 PyPI.org 安装此软件包:
pip install pysecstring
您可以直接从这个 github 存储库进行 pip 安装 - 这是开发存储库。
此外,您可以通过 git 克隆此存储库和它来安装poetry install
它。
git clone https://github.com/gwangjinkim/pysecstring.git
cd pysecstring
poetry install
用法
函数encrypt()
和decrypt()
作为ConvertTo-SecureString
(or Read-Host -AsSecureString
) 和ConvertFrom-SecureString
PowerShell 中的函数的纯 Python 等效项。
set_credentials()
要求您输入您的用户名和密码(星号输入),这会将您的凭据以SecureStrings
(十六进制二进制文件 - 在您的计算机内生成的种子)的形式存储在两个单独的文件中。
get_credentials()
读取这些存储的文件并将凭据打包到CredentialObject
PowerShell(但它的 Python 等效版本)中。当从这个凭证中探查.password
和.username
属性时,属性方法会立即将它们解密为纯文本(但它们不会以纯文本形式存储 - 以提高安全性)。
在您的脚本中的任何时间点和地点,用户名和密码都仅以其加密形式存储。
set_credentials()
并且get_credentials()
仅在同一台机器上运行时工作。因为不同的机器使用不同的盐进行加密和解密。
# save your credentials in the files `.\.user` and `.\.pass` in your machine:
username_file = '.\.user'
pass_file = '.\.pass'
set_credentials(username_file, pass_file)
# then PowerShell asks you for input of username and pass
# and these are stored in the username and pass files in an encrypted form - SecureString
# reads-in the SecureStrings and return them as one credential object
co = get_credentials(username_file, pass_file)
# these credential object you can probe using property methods to get the decrypted plain text forms on the fly
co.username # returns decrypted username
co.password # returns decrypted password
# the decryption happens when the properties are called (property objects)
该存储库最初是aznashwan/py-securestring
.
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
内置分布
pysecstring -0.1.9.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | c0b1575061d48abc185dccd577536208eff6f3168bfa3ce8697f53b3ea5e9af9 |
|
MD5 | 9de3f6a637e6b07df63e2debe6e1508e |
|
布莱克2-256 | 84cde788e12666d9aa4e6f97f234f960ba1935416fe804b1c978657d63fed286 |
pysecstring -0.1.9-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | e6e0add8696ac9d48766da68710729a71b06d3063be746d1c9abf90682c15ce4 |
|
MD5 | 1dbd1b7b6d75f83824febe4f35eaa07c |
|
布莱克2-256 | 17df42760781bb1a7e9886b695c52f58b087fa8c8eae7a97b70b8a722bf27e43 |