Per Engstrom

Greenhorn
+ Follow
since Feb 11, 2010
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Per Engstrom

Hi all!

I just received the note that I passed the SCJD assignment.

Thank you all!
Both for asking questions and answering them!

My solution ended up a little too ambitious at first.
So a lot of effort and agony was spent removing working but excessive code and functions.

I did end up with a solution with:
- RMI
- Buffered DB
- Create/Edit/Delete/Book/Un-book functions
- Icons!

Thanks again!!!
9 years ago
With input from the following thread I think the problem is with a corrupt key.

https://coderanch.com/t/133352/Security/BadPaddingException-DES

The key is converted into a string and stored.
That may be the reason why the CipherEncode-CipherDecode does not work...
The reason why the CipherStreams doesn't work is likely a combination of both failing to flush and key corruption...

Thanks for the help!
9 years ago
I think the cipher is correct... When writing to a FileOutStream, I can encrypt - decrypt and get the original back.

However after trying a few combinations I get the following (no Jar file involved):

StreamEncrypt - StreamDecrypt: OK
CipherEncrypt - StreamDecrypt: OK
CipherEncrypt - CipherDecrypt: OK
StreamEncrypt - CipherDecrypt: javax.crypto.BadPaddingException: Given final block not properly padded

Recap of Jar problem:

StreamEncrypt: Entry missing last 8 bits
CipherEncrypt: Entry contains the last 8 bits
StreamDecrypt: Result is corrupt
CipherDecrypt: javax.crypto.BadPaddingException: Given final block not properly padded

If I unpack the Jar file the encrypted entries diff with the direct-to-file-encrypted version
But the Jar file is generally ok, because non-encrypted files are correct.
9 years ago
Thanks!

Using the Cipher directly manages to copy the last 8 bytes.
Diffing the entries show that the rest of the files are identical.


But I still have some problems...

If I decrypt with the CipherInputStream the decryption completes w/o exception.
But the decrypted file is corrupt.


If I decrypt with the Cipher directly I get the following exception:

javax.crypto.BadPaddingException: Given final block not properly padded
at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
at com.sun.crypto.provider.DESedeCipher.engineDoFinal(DashoA13*..)
at javax.crypto.Cipher.doFinal(DashoA13*..)


What's going on here?!?
9 years ago
Hi,

I have a problem with encrypting a file while writing it into a Jar file.

I belive it it because only the number of bytes that I write into the CipherOutputStream are written into the JarOutputStream.
Writing the same stream into two entries (one not encoded) result in two entries of the same size.
But the encoded data increase in size if I write it into a FileOutputStream.

I get a similar problem if I forget to close the FileOutputStream.
But if I close the JarOutputStream I am unable to add more entries (!)...

I've tried to add a couple of flush() requests, but it doesn't seem to help.

Any suggestions?
9 years ago
Thanks for the info!
I feared that Java might not allow this, running in a sandbox and all...

Is there a way to ensure that the deciphered file is deleted on exit, and that it is not copied during execution?
9 years ago
Hi,

I'm looking into writing a license wrapper for a small utility application written in c++.
I want the java wrapper to both provide a nice GUI and enforce the license.

I imagine that the application will be encrypted and included in the jar-file.
A cipher to unchrypt it will be created by the wrapper based on conditions in the license (duration / executions whaterver...).


I want to do something like this:
(The first parameter to runtime.exec() on line 13 doesn't work.)


Thanks!
9 years ago
Hello,

The bean framework's VetoableChangeSupport has recently been brought to my attention.
However it may not be what I'm looking for. Perhaps someone can point me in the right direction?

I'm looking for a way to verify the combined change of several properties.
My current approach does not work.

Consider a simple game, where an entity can only move to an unocupied position.
Trying to validate the new position in two steps may result in both false-positive and true-negative results.






Thanks!
9 years ago
Hello,

After reading a lot of the posts on this board, I've got the impression that "less is more".
A simple but correct implementation is better than one with un-required functions with some error in them, even if the required functions are the same.

Unfortunately my URLyBird application has grown beyond the minimum requirements.
I now have “create”, “edit”, “un-book” and “delete” functions.
They seem to work, but you never know what the assessor will find...

Has anyone submitted an assignment with several extra functions and failed because of errors in the extra functions only?