Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8454825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:07:42+00:00 2026-06-10T12:07:42+00:00

So I made this basic chat application that is heavily reliant on security and

  • 0

So I made this basic chat application that is heavily reliant on security and encryption. I am running into a few problems in making everything work together.

I already managed to establish a connection between the client and server but I also want to have them share a common password which they will use to decrypt the whole chat session so only those two will view it. Also, the password is never transmitted over the wire for added security. This is where my problem starts.

As soon as my client and server connect, the server sends a user-specified challenge which is basically a string which the client will need to decrypt and send back, which then the server sees if it matches, and if it does communication will continue, much like WPA encryption in WiFi.

My encryption setup is AES, where I have a string and a key, then the whole thing is encrypted and decoded into Base64, then sent. The process is reversed obviously when decrypting. The server manages to send everything normally but the client returns null when decrypting even though it properly receives the encrypted string. I basically have one class that acts as a client or server depending on the user’s choice to become so.

Heres some code / stack traces:
Server Output:KCcOYuXTUD6SaXJQ4qIn7Q==
helloworld

Client Output:KCcOYuXTUD6SaXJQ4qIn7Q==
null

Encryption/Decryption Methods: http://pastebin.com/TtErYyz6

Socket Writing/Reading Method: http://pastebin.com/73QcQxva

Stacktrace on client side: http://pastebin.com/NdexZdyV
Note: When debugging line by line it just some how stops on like 27. in the socket pastebin link

Hope I have included enough detail to get a solution 😛
Thanks for any help, I have been working pretty hard on this project and even though some features are unnecessary, I will still try to implement them where applicable to learn as much as possible for when I start my programming degree next month

Complete code: http://pastebin.com/xkunfX37

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T12:07:43+00:00Added an answer on June 10, 2026 at 12:07 pm

    I found a few issues in the host verification code (verifyHost function).

    First, String comparisons are tricky:

    if(tempChallenge == decryptedChallenge){
    

    You’re comparing strings with ==, this will only work if they are the same string object. Proper string comparison is done with the String.equals function:

    if( decryptedChallenge.equals(tempChallenge) ){
    

    Second, input streams are also tricky. You’re reading everything from the input stream, and then attempting to read more. The server is sending one line to the client in challenge, and expects one back. While the client reads 3 lines.

    Third, CPU eating loop in the server code. It will use up a lot of CPU, and calling in.readline() will block and wait for input any way.

    while(!in.ready()){} // you can drop this line.
    

    Here’s the pastebin with the modified code: http://pastebin.com/JxazrA0G

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made this function to verify a user's twitter credentials. Its running on two
I made this bash one-liner which I use to list Weblogic instances running along
I made this simple function to filter the data. I add the symbols that
I have developed a basic Chat application in Java. It consists of a server
I am running a basic GWT application in IntelliJ, below is my code public
This is the basic idea: http://i51.tinypic.com/1zwcbgn.jpg So I made it like this (notice it
I've made a fairly basic AJAX chat with PHP & MySQL. The chat messages
Forgive me if this is basic. I've never made one before and can't seem
I have a basic SMS interception application on a windows mobile phone, currently this
This is going to sound so basic as to make one think I made

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.