如何使用加密密码登录用户名(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.