java登录系统

发布于 2024-10-04 01:35:31 字数 154 浏览 0 评论 0原文

我正在尝试为我的java程序制作一个多用户登录系统,目前我正在将用户名和密码与存储在文本文件中的md5哈希值进行比较。我希望能够为不同的用户提供对程序的不同访问权限,使用我目前使用的系统,如果打开文本文件,则可以轻松更改可访问性。有没有办法可以加密文件中的文本,然后在用户登录时解密它???谢谢

I am trying to make a multi user login system for my java program, at the moment i am compairing the username and password to md5 hashes stored in a text file. I would like to be able to geive different users different access wrights to the program, using the system i am using at the moment the accesablility would be easy to change if the text file was opend. Is there a way I could encrypt the text in the file and then unencrypt it when the user loggs in??? Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

徒留西风 2024-10-11 01:35:31

你可以看看这个全面的 Java 密码学指南。但是,我认为您最好使用数据库来存储用户名和密码,因为文本文件可以轻松删除或修改。对其进行加密只会使其更难以阅读。

请查看这里此处 了解 JDBC。如果你想要一个更健壮的框架,你可以使用 ORM,比如 hibernate。我发布的链接涉及 MySQL。它是一种非常流行的数据库服务器,并且与 Java 集成良好。您应该不会有任何关于 MySQL 的教程或任何类型的帮助的问题。

You can take a look at this comprehensive Java Cryptography guide. However, I think that you would be better off with a database to store the username and password since a text file could be easily deleted or modified. Encrypting it only makes it tougher to read.

Please take a look here and here to learn about JDBC. If you want a more robust framework, you can use and ORM like hibernate. The links I have posted refer to MySQL. It is a very popular Database server and integrates well with Java. You shouldn't have any problems finding tutorials or any kind of help with MySQL.

蓝咒 2024-10-11 01:35:31

还可以查看 JAAS 来限制对您的服务的访问(例如,基于角色)。

Also have a look at JAAS to restrict access to your services (e.g. based on roles).

沩ん囻菔务 2024-10-11 01:35:31

Md5 是一种单向哈希算法,您无法解密它,最好的方法是比较加密的字符串来验证内容

Md5 is a one way hash algorithmic you cant decrypt it back , best way is to compare the encrypted string to validate things

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文