This has nothing to do with encryption. The CR LF sequence is set in Windows wherever the output string of a printf() format contains the \n control. In linux (and UNIX) it is replaced with a single LF.
I cannot find BASE64Encoder so cannot try recreating your problem. However, as Bernhard explained in this response[^], these extra line terminators are added when you convert the data to a string. Keep it as a byte and see if you still have the problem.
- before you store the value in the database, remove all newlines.
- before you compare a value with a value from the db, remove all newlines.
Of course, you have to update your databse in case that you have some entries there already.
I am trying to code an application, like sync operation between two machines to transfer the files and folders through internet. Is it possible to use ftp or any other in java and write the application?
It's definitely possible. You can use FTP server on one machine and use a java program to synchronize a local folder with remote folder on FTP server. The FTP Server must be accessible from internet.
Other way is to write your own socket server implementation and use it for synchronization. Unlike the first implementation, this will allow you to initiate synchronization from either machine. With first it will be always from the machine on which java program is running.
Prasad P. Khandekar
Knowledge exists, man only discovers it.
I am writing the java application for encryption/compression which will be integerated in spring batch application to transfer large files.once it is done i will upload the source code here.
Then it's not working properly; but you have not given us enough information to help figure it out. There are plenty of working samples of sockets in Java to be found on the internet; maybe you should check your code against some of them.
- Wait for message
- Parse message into a list of strings. (3 in the above example)
- Put messages into expected output item (path, message1, messate2)
The above is a bit generalized. It could be less generalized or more so.
The important parts however are that
1. There is ONE message regardless of the data items (because presumably the data items are really part of one collection.)
2. The message defines the length (specifically the length of three strings and the total string count.)
3. The message is part of the communications API, it is not part of the rest of the application. The rest of the application does not know and does not care that the 'message' exists.
4. The rest of the application uses the communications API. It does know and does not care that TCP is being used.