一个简单的安全密码管理工具。
Why? 因为我无法信任网上的密码管理软件。另外,加密数据离开对应的密码管理软件无法解析,这个问题困扰着我。
所以,不如自己写一个简简单单的密码管理工具,所以就开始撸了这个小项目,( PyPi地址、 GitHub地址 ),通过以下方式来保证数据安全:
hpass
使用RC4算法进行数据加密存储。
密钥调度算法(KSA)
KSA 算法初始化长度为 256 的 S 盒。
def rc4_init_s_box(key):
# 将 0 到 255 的互不重复的元素装入 S 盒
s_box = list(range(256))
j = 0
# 根据密钥打乱 S 盒
for i in range(256):
j_step_1 = j + s_box[i]
j_step_2 = j_step_1 + ord(key[i % len(key)])
j_step_3 = j_step_2 % 256
j = j_step_3
s_box[i], s_box[j] = s_box[j], s_box[i]
return s_box
伪随机数生成算法(PRGA)
PRGA 算法根据 S 盒生成与明文长度相同的秘钥流,使用秘钥流加密明文。
def rc4_res_program(s_box, message):
res = []
i = j = 0
# 遍历明文长度的每一个字节
for s in message:
# i 和 j 定位 S 盒中的一个元素
i = (i + 1) % 256
j = (j + s_box[i]) % 256
# 与输入字节异或,同时,还改变了 S 盒
s_box[i], s_box[j] = s_box[j], s_box[i]
# 得到密文 k
t = (s_box[i] + s_box[j]) % 256
k = s_box[t]
# 由于异或运算的特性,使得加密与解密过程一致
res.append(chr(ord(s) ^ k))
# 如果输入的是明文,输出的就是密文
# 如果输入的是密文,输出的就是明文
return res
hpass -h
查看详细命令$ hpass -h
usage: hpass [-h] [-v] [-r PASSWORD_LENGTH] [-i] [-c]
Hello Password
optional arguments:
-h, --help show this help message and exit
-v, --version View version information
-r PASSWORD_LENGTH, --random_password PASSWORD_LENGTH
Randomly generate passwords containing uppercase and lowercase letters/numbers/symbols
-i, --initialization Create or specify a password storage file in the current directory
-c, --cli Start CLI Workbench
-t, --transfer Reset primary password (Change master password)
hpass -i
在指定目录中初始化密码数据文件$ hpass -i
Your primary password:
Enter your primary password again:
Find the password storage file in the current directory
Password storage file initialized successfully
hpass
进入工作台$ hpass
Your primary password:
H-Pass>
random
生成随机密码H-Pass> random 16
hiSVJ@77AEYFaZhu
add
添加一个新帐户H-Pass> add
The following is the information required for the new password :
Website = https://www.yeah.net/
Notes = 163 Yeah Mail
Username = xxxxxxx@yeah.net
Email =
Phone =
Password = hiSVJ@77AEYFaZhu
The new password has been successfully added!
search
搜索帐户数据H-Pass> search yeah
+----+-----------------------+--------------+
| ID | Website | Notes |
+----+-----------------------+--------------+
| 18 | https://www.yeah.net/ | 163 Yeah Mail |
+----+-----------------------+--------------+
get
查看帐户密码H-Pass> get 18
website = https://www.yeah.net/
notes = 163 Yeah Mail
username = xxxxxxx@yeah.net
email =
phone =
password = hiSVJ@77AEYFaZhu
set
更改帐户数据H-Pass> set 18 notes
Original notes = 163 Yeah Mail
Now notes = Yeah Mail
Password value modified successfully!
help
查看工作台帮助信息H-Pass> help
filepath - Print the absolute path of the password storage file
all - View the basic information of all password data
add - Enter a new password data
search - Find password data by keyword
random - Generate a secure password of specified length
get - View the password data of the specified id
del - Delete the password data of the specified id
set - Modify the key value of the password data of specified id
像往常一样,最简单的方法是使用pip:
$ pip install hpass
或者,您可以下载 hpass-x.x.x.tar.gz 安装文件:
$ pip install hpass-x.x.x.tar.gz
Pip 将为您安装依赖项 (colorama 和 PrettyTable) 。或者,您可以克隆GitHub仓库:
$ git clone https://github.com/hekaiyou/hpass.git --recursive
$ cd hpass
$ python setup.py install
hpass
是根据 MIT License 许可的免费开源软件。