Category Archives: Code Tidbits

Project Euler – Problem 6

Problem 6:
What is the difference between the sum of the squares and the square of the sums?

Project Euler – Problem 5

Problem 5:

2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?

Project Euler – Problem 4

Problem 4: Find largest palindrome from the product of two 3-digit numbers.

Playing with Jars

Recently, I came across a problem when updating a jar file.
How does one update a jar file with a class file using a particular packaging?

So you have a jar file named foo.jar with two elements in it, a package (fooPackage) containing multiple class files and your manifest.
You also have a class named bar.class that is packaged by fooPackage (*see bottom).
Do you think this will package it correctly?

>> jar uf foo.jar bar.class

No. Not really. It adds bar.class to foo.jar without a hitch, but does not keep your packaging path. Instead, it adds bar.class to foo.jar, but outside the package path you want.
If this was a stand-alone java application, this will not reflect your changes when running.

With this being said, I turned to a few external solutions to solve this problem.
After hours of frustration with a few programs (ie: DJ Java Decompiler), I finally ended up using WinRAR that did the trick and placed the bar.class in the correct package path (graphically).

*Note: When I say packaged by fooPackage I mean that the .java equivalent of bar.class has the code: package fooPackage;

GNU Crypto Usage Example in Java

So, how would one implement a cipher using the GNU Crypto algorithms?

First things first, get the jars at the very least.

Next, to ensure that your implementation of the Cipher in Java will work on all Java releases, ensure that you have the Base64Encoder file locally located within your project.

From here, a good modified working example can be found here: