如何使用加密密码登录用户名(java) [英] How to match username with encrypted password on login (java)

查看:159
本文介绍了如何使用加密密码登录用户名(java)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在oracle数据库中存储了用户名和密码。如何在登录时匹配用户名与
加密密码?

I have stored username and encrypted password in oracle DB. How I will match the username with encrypted password on login?

例如:username = abcd,encrypted password =#a11jsuy *& ^(actual password = abcd)。当用户想要登录时,他将使用username = abcd和password = abcd。但DB存储加密密码=#a11jsuy *& ^。如何匹配密码与加密密码和用户名登录?

For example: username = abcd, encrypted password = #a11jsuy*&^ (actual password = abcd). When user want to login at that time he will use username = abcd and password = abcd. But the DB stores encrypted password = #a11jsuy*&^. How to match the password with encrypted password and with the username to login?

我正在使用java和JSF。任何建议请。感谢提前。

I am using java and JSF. Any suggestions please. Thanks in advance.

我使用以下代码:

FUNCTION get_hash (p_loginname  IN  VARCHAR2,
                     p_password  IN  VARCHAR2)
RETURN VARCHAR2 AS

l_salt VARCHAR2(30) := 'PutYourSaltHere';

  BEGIN
    -- Pre Oracle 10g
    RETURN DBMS_OBFUSCATION_TOOLKIT.MD5(
      input_string => p_loginname || l_salt || UPPER(p_password));

  END;


推荐答案

您不需要匹配预先加密的密码。您的数据库存储加密版本,因此您可以使用用户输入的密码进行加密,然后查看它是否与数据库中的值相匹配。

You don't need to match the pre-encrypted password. Your database stores the encrypted version, so you can take the password the user inputs, encrypt it, and then see if it matches the value in your database.

这篇关于如何使用加密密码登录用户名(java)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆