如何记住各种各样的账户名和密码?

这是一个头疼的问题。
现在各种社区,商业网站,客户端app,全都使用 用户名+密码 或 邮箱+密码的登陆方式。当你使用了越来越多的服务,就意味着你要管理越来越多的账户和密码,怎么能把他们都记住呢?因为你也并不是每个网站都经常上,有时候需要了才发现用户名什么的根本就忘记了,这个时候难道还要再重新注册一个账户吗?把用户名和密码全部记下来?万一被别人看到了怎么办?放到手机里随身携带?每次用的时候还要掏出手机来查询,有新的账户再记录上去,你能保证做得到吗?
上周开始学python,发现用它来做一些小工具的开发再好不过了。对性能没有很高的要求,功能逻辑也很清晰简单,所以花了一天时间写了这么一个简单的密码管理工具。
本人是经常在Linux上工作的,比如现在写的博客就是再Ubuntu14.04上写的。用ln命令为这个文件创建一个软连接,放到/usr/bin/下,就相当与一个系统命令了。sudo ln -s /home/xieyuan/Document/python/manage_passwd.py /usr/bin/manpwd
使用方法写到代码中了,如果命令敲错了,会打印出所有的提示。使用起来也很方便。
1. 初始化,使用manpwd new创建一个record文件
2. 添加记录,manpwd add [name],比如你要存qq的账户,[name]就写qq。后面会提示你依次输入username, email, password,如果没有username或email,把其中一个空着就行,如果没有password(怎么 会没有,否则你用这个工具干嘛……)。输入完之后,会使用python的pickle模块将字典record的内容和类型信息都存到文件里,然后用base64模块将文件加密,这样即使被别人看到,也不知道里面是什么内容(加密方式可以换自己的,我这里抛砖引玉)
3. manpwd del [name] 删除一个记录
4. manpwd mod [name] 修改一个记录,如果有空内容会提示确认
5. manpwd qry [name] 查询一个记录
6. manpwd qry 列出所有记录的名字,有可能你忘了你存了哪些账户,使用这条命令可以让你看到你存的,比如qq,linkedin,淘宝等。utf-8编码,所以是支持中文的。
大家来用用看,看看效果怎么样把。欢迎提出更好的办法。
另外win平台上的我还在调试,稍后合并上去。

#!/usr/bin/env python
#-*- coding:utf-8 -*-
#Filename: manage_passwd.py'''this file can help you manage all of your acounts and passwds
that are hard to remember. with this tool, you just need to memorize
the name of your website or app account.Introducton:1.manpwd is a softlink to this file which has beed made a system commandin /usr/bin/manpwd2.the file which contains your password contents are encrypted, so if itsomehow obtained by anyone, it's hard for them to decrypt it. And beforethat, you can change them.3.in the following text, [] stands for the content you need to inputUsage:
1.manpwd new --- newly create a record file.2.manpwd add [name] --- add a record. [name] is the website's or app's name.if the record files are not created, add action is failed.name can't be same with recorded ones, or action os failed."manpwd del" and "manpwd mod" are both suitable3.manpwd del [name] --- del a record. if [name] is not in record, action failed.4.manpwd mod [name] --- modify a record.5.manpwd qry [name] --- query a specified name's informationRecord Structure
itemname: ...
username: ...
email:    ...
password: ...
'''import sys
import pickle
import os
import platform
import base64RECORD_FILE = '/home/xieyuan/.passwd_record/record.new'
TEMPFILE = RECORD_FILE + '.tmp'class PasswdManager:def __init__(self):self.user_file = RECORD_FILEself.record = {}self.usage = '''
Usage:
1.manpwd new        --- newly create a record file.2.manpwd add [name] --- add a record. when names conflict, fail3.manpwd del [name] --- del a record. name must be in record4.manpwd mod [name] --- modify a record. empty items be noticed5.manpwd qry [name] --- display a set of information of [name]6.manpwd qry        --- display all the names, in case you forget them'''def Dispatch(self):if len(sys.argv) == 2:if sys.argv[1] == 'new':self.CreateFile()elif sys.argv[1] == 'qry':self.QueryReocrd('')else:print(self.usage)elif len(sys.argv) == 3:if sys.argv[1] == 'add':self.AddRecord(sys.argv[2])elif sys.argv[1] == 'del':self.DelRecord(sys.argv[2])elif sys.argv[1] == 'mod':self.ModRecord(sys.argv[2])elif sys.argv[1] == 'qry':self.QueryReocrd(sys.argv[2])else:print(self.usage)else:print(self.usage)def isRecordExists(self):return os.path.exists(self.user_file)def DecodeFile(self):f = open(self.user_file, 'r+')filestring = f.read()newstring = base64.decodestring(filestring)ftmp = open(TEMPFILE, 'w+')ftmp.write(newstring)f.close()ftmp.close()with open(TEMPFILE, 'rb') as f:self.record = pickle.load(f)os.remove(TEMPFILE)def EncodeFile(self):with open(self.user_file, 'wb') as f:pickle.dump(self.record, f)f = open(self.user_file, 'r+')filestring = f.read()newstring = base64.encodestring(filestring)f = open(self.user_file, 'w+')f.write(newstring)f.close()def CreateFile(self):#first see if the file already existsif os.path.exists(self.user_file):self.FeedBack('record file', 'already exists')else:os.mknod(self.user_file)self.FeedBack('create record', 'ok!')def AddRecord(self, name):if self.isRecordExists():#if file not empty, load firstif os.path.getsize(RECORD_FILE) > 0:self.DecodeFile()#if file empty, write directly if name in self.record:self.FeedBack('names', 'conflict...')else:user = raw_input('username: ')email = raw_input('email: ')passwd = raw_input('password: ')self.record[name] = (user, email, passwd)self.EncodeFile()self.FeedBack('add record', 'ok!')else:self.FeedBack('record', 'not found...')def DelRecord(self, name):if self.isRecordExists() and os.path.getsize(RECORD_FILE) > 0:self.DecodeFile()if name in self.record:del self.record[name]self.EncodeFile()self.FeedBack('Delete record', 'ok')else:self.FeedBack('record', 'not exists')else:self.FeedBack('record', 'not exists')def ModRecord(self, name):if self.isRecordExists() and os.path.getsize(RECORD_FILE) > 0:self.DecodeFile()if name in self.record:print('old -->')self.ShowRecord(self.record[name])print('new -->')user = raw_input('username: ')email = raw_input('email: ')passwd = raw_input('password: ')if user == '' or email == '' or passwd == '':print('there is empty item(s), sure to modify?[y/n]')sure = raw_input()if not sure == 'y':self.FeedBack('Modify record', 'abort')returnself.record[name] = (user, email, passwd)self.EncodeFile()self.FeedBack('Modify record', 'ok')        else:self.FeedBack('record', 'not exists')else:self.FeedBack('record', 'not exists')def QueryReocrd(self, name):if self.isRecordExists() and os.path.getsize(RECORD_FILE) > 0:self.DecodeFile()if not name == '':if name in self.record:self.ShowRecord(self.record[name])else:self.FeedBack('record', 'not exists')else:for key in self.record.keys():#   ShowRecord(self.record[key])print(key + ' ')else:self.FeedBack('record', 'not exists')def FeedBack(self, typeme='', infostr=''):print(typeme + ' ' + infostr)def ShowRecord(self, tup):print('username: {0}\nemail: {1}\npassword: {2}\n'.format(tup[0], tup[1], tup[2]))if __name__ == '__main__':app = PasswdManager()app.Dispatch()

基于python的密码管理工具相关推荐

  1. python 量化交易_基于Python的量化交易工具清单(上)

    -- Python量化工具清单 -- 以下内容来源于Wilson Freitas的Github项目"Awesome Quant".原文中包含了丰富的语言类别,但是后续介绍主要针对P ...

  2. python商业分析_科研进阶 | 纽约大学 | 商业分析、量化金融:基于Python的商业分析工具...

    科研进阶 | 纽约大学 | 商业分析.量化金融:基于Python的商业分析工具(8.22开课)​mp.weixin.qq.com 课题名称 = 基于Python的商业分析工具 = 项目背景 数据分析为 ...

  3. py225基于python的家政管理系统设计

    开发环境 项目编号: py225基于python的家政管理系统设计 开发语言:Python python框架:django 软件版本:python3.7/python3.8 数据库:mysql 5.7 ...

  4. 个人信息管理PIM——密码管理工具软件

    密码管理工具 以KeePass为主,结合LastPass在线浏览器网页密码.有钱银可以考虑1Password. KeePass LastPass 1Password 价格费用 免费开源 普通版:免费 ...

  5. 全平台最佳密码管理工具大全:支持 Windows、Linux、Mac、Android、iOS 以及企业应用

    原文 当谈到网络安全的防护时,从各种网络威胁的角度来看,仅安装一个防病毒软件或运行一个安全的 Linux 操作系统,并不意味你就是足够安全的. 今天大多数网络用户都容易受到网络攻击,并不是因为他们没有 ...

  6. lastpass密码管理工具使用教程

    现在移动互联网发展异常空气,无论访问哪个平台或者网站必须要注册账号,日子久了就会发现最痛苦的就是记住这些网站的密码.因为我们不可能将所有的网站都是设置同样的的账号密码,因为国内网站用户数据库被泄露的事 ...

  7. CentOS 下 yum(基于rpm的包管理工具) 命令详解

    Yum: 即Yellowdog Update Modifier,是一种基于rpm的包管理工具 yum命令使用示例(转载自:https://www.cnblogs.com/vathe/p/6736094 ...

  8. gorm 密码字段隐藏_非常专业且免费的密码管理工具

    KeeWeb是一个非常专业的密码管理工具.这款工具支持Mac OS X,Windows和Linux平台,不需要任何安装和工作在所有现代浏览器,搜索任何条目或查看所有文件中的所有项目作为一个列表.功能非 ...

  9. python模块管理工具,Python的包管理工具

    Python的包管理工具 python包管理工具 python包管理工具简介 distribute是setuptools的取代,pip是easy_install的取代. Distribute是对标准库 ...

最新文章

  1. javase 超市库存系统
  2. JSON.parse与eval的区别
  3. 程序员必知的8大排序(三)-------冒泡排序,快速排序(java实现) .
  4. 每天十分钟系列:JS数据操作之神奇的map()
  5. 【CodeForces - 255C】Almost Arithmetical Progression (dp,离散化)
  6. es 吗 查询必须有sort_ElasticSearch DSL之From/Size,Sort
  7. STM32 - 定时器的设定 - 基础 01 - Timer Base - Prescaler description - Upcounting mode
  8. adb命令安装apk 来学习吧
  9. 自定义服务器网址,小白新手如何在服务器上搭建一个自己的网站
  10. 我们可以拥有多少级指针?
  11. 在Ubuntu10.10下升级内核到2.6.36使用systemtap
  12. protocol buffer与json对比
  13. 金属、指纹、全网通该有的都有 中兴小鲜3正式发布
  14. Linux Ubuntu系统fwknop单包授权认证(SPA)流程
  15. CSS命名规范 BEM 颜色 【全局】
  16. C#转换Excel表格中的科学计数法数字
  17. ng-template、ng-container、ng-content 的用法
  18. HTML元素的宽度计算
  19. 计算机蓝屏代码0xc0000020,Win10打开软件提示“损坏的映像 错误0xc0000020”的解决方法...
  20. TabIndex 属性:Tabindex=-1 与Tabindex=0、任意数字

热门文章

  1. 勒索软件:帮派联手,拍卖被盗数据
  2. spring web请求statuscode = 200 无响应值_200行代码,7个对象——让你了解ASP.NET Core框架的本质[3.x版]...
  3. 发展前景好、薪资高,计算机行业成为许多人改变命运的首选!
  4. 商城管理系统的数据表从属关系+navicat建表操作+数据库文件转储并入代码操作
  5. IT 从业者应该了解的著作权知识
  6. 公司U07 随机变量,NPV与实物期权 习题解读
  7. DeFi新玩法丨3分钟了解无需预言机的链上期权协议Primitive
  8. python打印星图_Python中的星图
  9. idea设置git忽略文件
  10. 计算机基础知识论文统一格式,计算机基础论文范文