You could use the java.security.MessageDigest class.
To encrypt
initialize by e.g.
locMsgDigest = MessageDigest.getInstance("MD5"); // factory method
and then encrypt by
pinRndStr=pin+rnd;
pinRndByteArr = pinRndStr.getBytes();
resultByteArr = locMsgDigest.digest(pinRndByteArr);
encryptedPin = new String(resultByteArr);
with definitions
String pin="test12345678";
String rnd = "0000";
byte[] pinRndByteArr;
byte[] resultByteArr;
String encryptedPin;
The to be encrypted PIN is here: test123456780000, consisting off a PIN and a Random
Number:
the random number is as simple case 0000.
This PIN is encrypted to the String "encryptedPIN".
See the JDK API for details.
Axel, Lannion/France
> -----Original Message-----
> From: Deepak C S [SMTP:[EMAIL PROTECTED]]
> Sent: lundi 8 janvier 2001 09:35
> To: [EMAIL PROTECTED]
> 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