This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes Decrypt String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Decrypt String" Watch "Decrypt String" New topic
Author

Decrypt String

Mathew Mintalm
Ranch Hand

Joined: Feb 21, 2010
Posts: 103

Hello, I made my multi threaded client <-> server application.

How does it work?

1. Client try connect to the server
2. Server accpet clients
3. Client send String to the server
4. Server compare this string with String from server
5. If string sent from client equals to server string server send "stringIsOk" String
6. If client receive "stringIsOk" string, will print something.

Ok, it works as it should, but my friend told me thats unsafe, and told me that I should read about how to encrypt/decrypt.

I found this way to encrypt String (MD5)



But till now I couldn't code or find any way to decrypt string received with this way.

If someone can help me, would be great, thanks.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 20041
    
  30

MD5 cannot be decrypted. It's one-way only. Use javax.crypto.Cipher instead, with an algorithm like AES.

An alternative is to use SSLServerSocketFactory to create SSLServerSocket instances instead of regular ServerSocket instances, and SSLSocketFactory to create SSLSocket instances instead of regular Socket instances.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Mathew Mintalm
Ranch Hand

Joined: Feb 21, 2010
Posts: 103

Ok, thank you for information.
 
Consider Paul's rocket mass heater.
 
subject: Decrypt String
 
It's not a secret anymore!