Skip to main content

从 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-SecureStringPowerShell 中的函数的纯 Python 等效项。

set_credentials()要求您输入您的用户名和密码(星号输入),这会将您的凭据以SecureStrings (十六进制二进制文件 - 在您的计算机内生成的种子)的形式存储在两个单独的文件中。

get_credentials()读取这些存储的文件并将凭据打包到CredentialObjectPowerShell(但它的 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 (4.9 kB 查看哈希

已上传 source

内置分布

pysecstring-0.1.9-py3-none-any.whl (5.0 kB 查看哈希

已上传 py3