This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.

Abhi Ram

Greenhorn
+ Follow
since Apr 19, 2014
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Abhi Ram

Paul Clapham wrote:

Right. So not only do you throw away all of the cipher text except the last line when you read it, when you write it you're appending an unnecessary line-end character.

But really your cipher text isn't a series of lines anyway, is it? It's just a series of characters. So you should really stop treating it as lines. Don't use any methods which write lines or read lines, just write all the characters to the file and then read them all back.



if i use character stream, when i read from file I am getting it as Integer. Again I need to do conversion

Can you give example
10 years ago
@paul - It is not series of lines , just a series of characters.

ok , I will write characters to the file and then read them back

Thanks , will let you know
10 years ago
Here is the code when user clicks send button - I do encrypt and store in file

10 years ago
Yes Paul thats my goal

Basically when i encrypt the text , i store it in file (cipher.txt) to later use it to decrypt it

also can you tell me how to store value in global variable which I can use later rather then in file
10 years ago
I corrected my mistake in above code and made below changes but getting different error

Error"Not PKCS#1 block type 2 or Zero padding" exception "

Run ChatClient.java - Dialog box is shown where user enters username. Then private key and public key are generated and stored in C:/username/publickey,C:/username/privatekey.

Above step repeats when we run ChatClient.java again.

Then user1 sends message to User2 in encrypted form using User2 public key (Which is working fine)(after encryption , message is stored in text file) then User2 clicks decrypt button which decrypts the text (reads the encrypted text from file) using User 2 private key then display in textarea.

When I trying to decrypt I am getting "Not PKCS#1 block type 2 or Zero padding" exception

10 years ago
How to edit my original post ?
10 years ago
Sorry for small image

So in my chat application (As you can see two GUI with same GUI components)

In Client A - user types text and clicks send button, which will display the encrypted text in Text Area in Client B.

This is done using following line



where pw is

There is decrypted button in my GUI, which when clicked would display the text in another text area named decryptedtext. I do this by

I have added listners to each button and in action performed i choose what to displayed based on which button clicked




Now problem is : When user clicks Decrypt button (in Client A button i.e where we click send button) it displays the text in textarea (decrypttext) but if i click same Decrypt button in Client B(where it displays the text sent from Client A) nothing is getting displayed. How to make it work in both windows

10 years ago
Thanks Richard - That makes sense

Can you explain second problem(in my second post)
10 years ago
Thanks Paul

I understood the mistake I am making I.E

I am encrypting using RSA public key but while decrypting I using different key. Thats why different output.

Which brings me to different problem

Please take a look at the image

10 years ago
I created a Simple RSA enabled chat application in java.

Message sent from Client A (or Client B) in encrypted form, the encrypted message is displayed on Client B (or Client A if sent from B) text area in encrypted form. User clicks decrypt button on client B then we will get the value from text area () then perform necessary cleaning then decrypt Problem: text2 is not in readable format (Look the attached Image ).

I have attached ChatClient.java ( where GUI and rsa code runs) and Chatserver( to run the server)



Chat Client





Code - which runs decrypt button is clicked
10 years ago