python 保护文件的最佳方法?
我想保护一个文件,我不允许用户更改它(只有我的应用程序可以更改它)并且无法删除。我知道 Windows Defender,但它运行得并不完美。 我喜欢这样的东西: 首先我有一个txt文件,该文件的名称是sample.txt,
from protector import protect_with_lock
protect(file="sample.txt",password_lock="12345")
在我运行此代码后,该文件夹为空。
from protector import unlock
unlock(file="sample.txt",password_lock="12345")
这个文件回来了 感谢您的帮助!
I want to protect a file , i don't allow user can change it (only my app can change this) and can't delete. I know Windows Defender but it's not work perfect.
I like something like this:
first i have a txt file, this file's name is sample.txt
from protector import protect_with_lock
protect(file="sample.txt",password_lock="12345")
after i run this code this folder is emty.
from protector import unlock
unlock(file="sample.txt",password_lock="12345")
and this file is come back
Thanks for help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在任何系统上,进程可以执行的操作仅取决于用户 ID,而不取决于应用程序。您想要的只能在类 Unix 上实现,其中应用程序可以在特定用户下运行,这要归功于设置用户 ID 功能。在 Windows 上,唯一可能的方法是拆分应用程序:
On any system, what a process can do only depends on the user id and not on the application. What you want would only be possible on a Unix-like where an application can run under a specific user thanks to the set user id feature. On Windows, the only possible way is to split the application :
锁定和隐藏文件夹的步骤。
如果您被困在某个地方,请告诉我。
Steps to Lock and hide a folder.
Let me know if you get stuck somewhere.