LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-07-2006, 08:12 AM   #1
Clemente
Member
 
Registered: Aug 2003
Distribution: Debian, Ubuntu
Posts: 188

Rep: Reputation: 30
Java: Password encryption


Hi all,

I have to write a java class, that encrypts user passwords for linux systems.

Encrypted passwords look like
Quote:
Cleartext: example123
Encrypted: $1$WSkRNdS1$wEjaljTpo9RJeAUmTOmyq.
(I got this passwd from a shadow file)

After trying and googling, I don't know really
a) what algorithm is used to produce the encrypted password (it is not CRYPTed) and
b) how to encrypt with java.

The JCE seems to support two-way encryptions and some digests only. I tried the digests like md5, but nothing produced something identical (or even similar) to the given encrypted passwords.

Can anyone point me the correct direction?
Thanks a lot,
Clemente
 
Old 02-07-2006, 08:14 AM   #2
scuzzman
Senior Member
 
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851

Rep: Reputation: 47
The encryption, if this is for a standard login, is DES. This should prove useful: http://javaalmanac.com/egs/javax.crypto/DesString.html
 
Old 02-07-2006, 09:00 AM   #3
Clemente
Member
 
Registered: Aug 2003
Distribution: Debian, Ubuntu
Posts: 188

Original Poster
Rep: Reputation: 30
Hi scuzzman!

Thank you for quick answer. I studied/tried the code behind your link. It works, but creates other ciphers, and it creates another cipher each run.
A key is necessary to use DES. If the system uses DES, what key comes to action? Is it derived from the username?

Maybe I am to dumb, but I don't find the big key (for my problem, not DES :-) )
Clemente
 
Old 02-07-2006, 09:30 AM   #4
Clemente
Member
 
Registered: Aug 2003
Distribution: Debian, Ubuntu
Posts: 188

Original Poster
Rep: Reputation: 30
Finally I got it.
The encryption was MD5, and I found a Java md5encryption implementation from IBM. Links are posted below.

The encrypted password gives following information between the "$" chars:
$1$QnRtOx4v$DgS/DY84XDmasEHZKqdfv.
$1$ : Magic key, that indicates, that the string is a md5 cipher
$12345678$ : Salt used to encrypt, 8 characters

http://www-128.ibm.com/developerwork...cale=worldwide

The site is linked by this one:
http://www-128.ibm.com/developerwork...ry/l-md5crypt/

Perhaps someone can use this one, too

Clemente
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux password encryption jawad bokhari Linux - Security 13 08-23-2012 07:26 PM
Password Encryption morningkiran Linux - Security 2 10-10-2004 07:17 AM
WEP encryption password fatrandy13 Linux - Wireless Networking 14 09-15-2004 02:39 PM
password encryption Lanmate Linux - Security 2 12-26-2003 04:15 AM
Password encryption???: shakeeb Linux - General 4 11-07-2003 07:50 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration