I am developing an java application for for login autentication form, I have pre saved username and password in my database. When admin enter his credetials, it validates to my DB and gives access to actual application

Now, my application is used by admin and database is managed by DBA. and I have a database named with USERS in which I saved admin credentials.
when DBA tries to access USERS database, so that he can easily get access admin application using credentials in USERS database.

For all this, I want to encrypt admin credentials. I wrote a program where my admin application automatically creates USERS database and its credentials in the begining itself and then it asks me to enter credentials.

How could I encrypt admin credentials during initialization..Please help.

Thank you.

not as good with java as i am in c++ but i think you should lookup the hashCode function in javadocs. it directly parses any string into a hashkey. however you will need to write a function to convert the hashCode back into it's base string.

convert the hashCode back into it's base string.

Not sure that is possible. Its a many to one relationship.

How could I encrypt admin credentials during initialization

For this you could use a encryption strategy may be like the MD5 and store it in the DB pwd field. And when user enter the pwd in application you should encrypt that as well and then compare the entered value and value in DB.

when DBA tries to access USERS database, so that he can easily get access admin application using credentials in USERS database.

This way the DBA would be only seeing the encrypted value in DB hence would not get to know the value to enter for credentials

Zaad's suggestion is a good way to go. You can improve it slightly to protect against people searching the web for well-known MD5 values by "salting" the password, ie adding some extra garbage characters (hard coded in your program) to the password before calculating the MD5 digest.

This article has been dead for over six months. Start a new discussion instead.