This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv 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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Decrypt String" Watch "Decrypt String" New topic

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

Joined: Oct 27, 2005
Posts: 20193

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.

How To Ask Questions How To Answer Questions
Mathew Mintalm
Ranch Hand

Joined: Feb 21, 2010
Posts: 103

Ok, thank you for information.
I agree. Here's the link:
subject: Decrypt String
It's not a secret anymore!