一个简单的api,用于加密python dict并将其保存到文件中。

pydictfileenc的Python项目详细描述


pydictfileency

一个简单的api,用于使用aes256将python dict加密到文件中。交互直接在文件和内存之间(不会创建解密的file.tmp)。加密的数据以字符串形式保存在光盘上的文件中。如果一个人在开发一个单线程应用程序,它可以被用作加密的“sql”。 这个api是stackoverflow上答案的集合。

安装

pip install pydictfileency

用法

python dict(一组)被收集在将直接操作的“容器”中。

示例和API

from pydictfileency import PyDictFileEncy

创建容器

#-----------------------------------------------------
# create a new filedict (with password = 'password')
container = PyDictFileEncy('encrypted.dat','password')
container.connect()
# a file is created. One can check the context in it.

连接到它(验证密码)

#-----------------------------------------------------
# connect to a filedict
container = PyDictFileEncy('encrypted.dat','password')
container.connect()
print(container.IsConnected())
# a filedict is connect. One can try another password.

创建表(表是python dict)

#-----------------------------------------------------
# create a table
container = PyDictFileEncy('encrypted.dat','password')
container.connect()
container.CreateTableIfNotExist('testTable')
# remenber to save it
container.Save()

显示所有表格

#-----------------------------------------------------
# get all the tables in container
container = PyDictFileEncy('encrypted.dat','password')
container.connect()
# return a python dict 'dict_keys' type
l = container.GetTableList()
print(l)

在容器中获取python dict。你可以做手术。

#-----------------------------------------------------
# get a normal python dict in the container so one can interact with it
container = PyDictFileEncy('encrypted.dat','password')
container.connect()
d = container.GetTable('testTable')
print(type(d),d)
# ---  inser an element
d['new'] = 'hellow'
# remenber to save it
container.Save()

删除表格

#-----------------------------------------------------
# remove a table
container = PyDictFileEncy('encrypted.dat','password')
container.connect()
container.DropTable('testTable')
# remenber to save it
container.Save()

重置新密码

#-----------------------------------------------------
# reset password
container = PyDictFileEncy('encrypted.dat','password')
container.connect()
container.SetPassword('newpassword')
# remenber to save it
container.Save()
# the container itself is already renewed
print( container.IsConnected() )

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java使用prepared语句在oracle中插入日期   对点具有双重值的java   使用多个通配符的java请求映射   java Springboot为什么要设置springbootstartertomcat   除了对JavaBean的请求之外,还使用servletContext的servlet   java如何清除OCSID。返回到池的连接时的CLIENTID JDBC客户端信息属性   将整型数组转换为光栅Java   java使用对象引用作为互斥锁   java为什么在编程语言中使用sin函数返回奇怪的sin值不像计算器   java如何将JButton链接到对象并调用相关方法   php用Java发送POST数据   导航属性的java模拟加载   java多个活动错误Android试图对空对象引用调用虚拟方法“”   java Android更改ActionBar文本颜色   如何使用带有java反射且不带开关的parant引用创建子类