主要用来管理各登录密码
只需要记住用户名和用来加密的字符串或者文件。
可以选复制到剪贴板或者输出到屏幕
#!/usr/bin/env python3
import os
import sys
import getpass
import hashlib
import argparse
def md5sum(file):
md5_hash = hashlib.md5()
try:
with open(file, 'rb') as f:
for byte in iter(lambda:f.read(65536), b''):
md5_hash.update(byte)
return md5_hash.hexdigest()
except IOError as e:
print(e)
pass
def generate_password(src, user, key, length=12):
password = hashlib.sha256((src + user + key).encode()).hexdigest()
password = password[0:length]
return password
class ClipBoard():
@staticmethod
def copy(message):
platform = sys.platform
if 'win32' in platform or 'cyg' in platform:
cmd = 'echo {}|clip'.format(message)
elif 'linux' in platform:
cmd = 'echo {}|xclip'.format(message)
os.system(cmd)
class GetKey(argparse.Action):
def __init__(self, option_strings, dest=None, nargs=0, default=None, required=False, type=None, metavar=None, help=None):
super(GetKey, self).__init__(option_strings=option_strings, dest=dest, nargs=nargs, default=default, required=required, type=type, metavar=metavar, help=help)
def __call__(self, parser, args, values, option_strings=None):
key = getpass.getpass("key or file path:")
setattr(args, self.dest, key)
def main():
parser = argparse.ArgumentParser(description="generate password")
parser.add_argument("src", help="target")
parser.add_argument("user", help="username")
parser.add_argument("key", action=GetKey, help="the encypt key of file")
parser.add_argument("-l", dest='length', type=int, default=12, required=False, help="the length of password")
parser.add_argument("-c", dest="copy", action="store_true", default=False, required=False, help="copy to clipboard")
args = parser.parse_args()
src = args.src
user = args.user
key = args.key
length = args.length
copy = args.copy
if os.path.isfile(key):
key = md5sum(key)
password = generate_password(src, user, key, length)
if copy:
ClipBoard.copy(password)
else:
print(password)
if __name__ == '__main__':
main()
用法 python3 pypass.py 网站地址 用户名 -l 密码长度 [-c]
1
2exploring 2019-03-06 17:16:48 +08:00
pass 不好吗。。
|
2
ifaii 2019-03-06 19:13:10 +08:00 via iPhone
1passwd
|
3
hundan 2019-03-06 21:42:46 +08:00 via Android 2
我不信楼主会用这个来管理自己密码
|
4
CallMeReznov 2019-03-06 21:46:23 +08:00
我选择 excel。。。。或者 lastpass
|
5
shuax 2019-03-06 21:51:59 +08:00
chrome 自带挺好用
|
6
indev 2019-03-06 23:39:55 +08:00
再来一次,推荐 lesspass,之前是用 nodejs,最近改为 python 了
https://github.com/lesspass/lesspass |
7
masker 2019-03-06 23:51:55 +08:00 via Android
chrome 智能填充。chrome 推荐密码。
|
8
harde 2019-03-07 00:25:36 +08:00
就目前来说,1password 足够用
|
9
d0m2o08 2019-03-07 08:22:45 +08:00
曾经我也想撸一个自己的,后来用了 keepass+dropbox 组合
|
10
set01 2019-03-07 08:47:59 +08:00
lastpass 挺好的,免费版就够用了
|
11
ysc3839 2019-03-07 12:43:29 +08:00
我选择 KeePass。
|