Can a jar file modify the contents of an encoded text file when we reimport it?

I have a Java application where I need to protect the contents in a text file before exporting it to a jar file. Therefore, I encode the file using the BlowFish algorithm provided by "javax.crypto.Cipher". And I decipher it on the fly.

Everything works fine when I run the application from my workstation. But as soon as I export the application to a jar file and run it. It causes an error in the part of the code that tries to decrypt the contents of the protected text file. Error:

javax.crypto.BadPaddingException: this final block is not inserted correctly

Does the export-jar process file modify the contents of the included text file anyway, for example, is this encoding?

+4
source share
1 answer

The Jar command and the java.util APIs for generating zip and jars do not process encodings - they treat files as binary. I would look at your build process to see if you have filters for replacing objects, etc. I saw how Maven and ANT messed up binary files with text file names ... By the way, does your encoded file have a .txt extension?

0
source

All Articles