密码保护 CSV 文件
我正在使用 csv 文件来验证用户登录。是否可以使用密码保护 CSV 文件?我不希望任何人能够通过 url 下载 csv 文件。我用谷歌搜索,发现无法用密码保护 csv 文件。还有其他方法可以用密码保护文件吗?
I am using a csv file to authenticate user login. Is it possible to password protect the CSV file? I do not want anybody to be able to download the csv file through url. I googled and I found out that it is not possible to password protect a csv file. Is there any other way I can password protect the file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
简而言之,答案是否定的:CSV 是纯文本格式,而不是 Excel。
长的答案是:您永远不应该将安全相关信息放入可通过网络服务器访问的文件夹中。将文件移动到可以从 PHP 访问但位于 Apache 文档根目录之外的文件夹中
the short answer is no: CSV is a plain text format, it's not Excel.
the long answer is: you should never put security relevant information into a folder which is accessible via the webserver. move the file into a folder you can access from PHP but which is outside of your document root in Apache
使用加密将其压缩为 ZIP 文件。但是,每次您想要读取它时,都必须对其进行解压缩/解密。
请参阅 Powerarchiver、winrar,或其他压缩实用程序以获取更多信息。
Compress it in a ZIP file using encryption. You'll have to decompress/unencrypt it each time you want to read from it, however.
See Powerarchiver, winrar, or other compression utilities for more information.
如果使用 Apache,请使用 .htaccess 文件拒绝对该文件的访问。更好的是,将文件存储在 webroot 之上的某个位置。例如,如果您的网络服务器位于
/home/username/htdocs/
,您可以将该文件存储在/home/username/data/logins.csv
中。If using Apache, use a .htaccess file to deny access to that file. Better still, store the file somewhere above the webroot. For example, if your webserver is located at
/home/username/htdocs/
, you could store the file at/home/username/data/logins.csv
.如果您担心有人下载该文件,请将其放在不可下载的位置。您的网络服务器只会返回一组特定目录中的文件。如果您的 CSV 文件不在其中之一,则没有人能够下载它。
If you're worried about someone downloading the file, put it someplace that isn't downloadable. Your webserver will only return files from a specific set of directories. If your CSV file is not in one of them, nobody will be able to download it.