Here' my old code -hope it helps you. There's only a single function that
takes a String as an inpu and returns the encryoted version of the string
itself. Digest used is (as standard) MD5. Java distributions normally DO NOT
include other common digests, like MD2 or SHA-1, even if they're specified
in the Java Security specification.
Good luck :)
--------------------------------------------------------------
import java.security.*;
import sun.misc.*;
/* other code */
MessageDigest md5;
public String crypt(String message) {
byte[] buffer=new byte[16];
try {
if (md5==null) {
md5=MessageDigest.getInstance("MD5");
}
md5.update(message.getBytes(), 0, message.length());
buffer=md5.digest();
return new BASE64Encoder().encode(buffer);
} catch (Exception e) {
}
}
--------------------------------------------------------------
[Andrea Stocco]
DREAMWARE S.r.l.
Multimedia Productions
----------------------------------------
Via Pascoli 19 - 19125 La Spezia - Italy
Tel. ++39 0187 500968 Fax ++39 0187 516388
Via Caneva 56 - 33013 Gemona del Friuli, Udine - Italy
Tel. ++39 0432 971811 Fax ++39 0432 971910
----- Original Message -----
From: Deepak C S <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, January 08, 2001 9:35 AM
Subject: Password encryption in Java
> Hi,
>
> Can anybody tell about" How we can encrypt Passwords in Java??"say
> like Perl's or Unix Crypt function??
>
> i mean,
>
> Is there any Java equivalent of unix crypt() func??
>
> thanx in advance,
> Deeps
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html