Hi Arul,
  U can use the MessageDigest Class available in the java.security package.
Check out the following code...

private String encrypt(String password) {
  byte[] buf = password.getBytes();
     MessageDigest algorithm=null;
     try {
         algorithm = MessageDigest.getInstance("SHA-1");
     }catch (NoSuchAlgorithmException e) {
         System.out.println(e);
    }
     algorithm.reset();
     byte[] digest1 = algorithm.digest(buf);
     return new String(digest1);
 }

Arul wrote:

> Hi Guys...
>
> Could any body tell me how to encrypt the password and save it in a
> database..
>
> Say my scenario goes like this...I write a login component in EJB and that
> checks whther the username and password is correct and based on the login
> name it gives the login permission.
>
> but before that when i save the user information , i should encrypt his
> password and save it in the datbase...It should be a irreversible
> encryption.
>
> When ever my component validates the username and password ,it shuld encrypt
> the passwrd and check for it ...
>
> Any ideas...
>
> Arul
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to