The arc90 lab is the playground of arc90 - a New York-based technology and strategic consulting firm. The lab is a place for us to share our ideas, tools and the occasional experiment in web technology. All ideas, experiments and tools are licensed under Creative Commons.

licensed under creative commons

This site is licensed under a Creative Commons Attribution 2.5 License.

Tools

Java Encrypter

Encrypter is a simple Java class for encrypting a java object to text, and later reversing the process. It's useful for transferring sensitive data over an unencrypted channel, such as in an XML document or email.

DES encryption is performed using Java's SealedObject class, and Base64 encoding is handled by the public domain Base64 class.

What is this?

A .jar file containing Encrypter class, as well as the original source code.

How do I use it?

Download and extract the archive
Add the target/Encrypter-X.X.jar to your classpath.
Instantiate the class and call its method

Examples are provided below.

Download the code

Click on the icon below to download the source code:

Download

The archive contains the original source code (in src/main/java), JUnit unit tests in (src/test/java) and the complied .jar (at target/Encrypter-X.X.jar).

Examples

Here's an example of instantiating Encrypter, encrypting an object to a String, and decrypting a String to an object. Typically, the encrypting and decrypting would be called in separate places and not one after another as in this example.

package com.arc90.example;

import java.util.ArrayList;
import java.util.List;
import com.arc90.labs.encrypter.Encrypter;

/**
 * Example usage of the Encrypter class
 */
public class EncrypterExample
{
	public static void main(String[] args)
	{
		String password = "cW1dm0re";
		
		/*
		 * Create the object to encrypt (must be Serializable)
		 */
		List secrets = new ArrayList();
		secrets.add(4);
		secrets.add(8);
		secrets.add(15);
		secrets.add(16);
		secrets.add(23);
		secrets.add(42);
		
		/*
		 * Encrypt the object into a String named cipherText
		 */
		Encrypter> encrypter = new Encrypter>();
		String cipherText = encrypter.encryptAndSerialize(secrets, password);
		
		/*
		 * Print the encrypted String
		 */
		System.out.println(cipherText);
		
		/*
		 * Decrypt the String
		 */
		List reversed = encrypter.deserializeAndDecrypt(cipherText, password);
		
		/*
		 * Print the decrypted object
		 */
		for(Integer i : reversed)
		{
			System.out.println(i);
		}
	}
}

Licensing

This arc90 tool is licensed under the Creative Commons Attribution-Share Alike 3.0 license.

Discuss Encrypter

You can send feedback on Encrypter by adding a comment to the original blog post.

Digg Del.icio.us