GPG Quick Guide

I have many friends who are having a few Issues getting the grips of GPG and public key encryption so I decided to make a quick post to cover the basics.

Firstly a video to explain the concept of public key encryption

diffie-hellman key exchange

A good way to learn is the command line as It requires no front end software and is installed on nearly every linux system by default . The command line? No, it’s not hard as long as you have a basic understanding of how asymmetric cryptography works (i.e. you’ve at least read the wikipedia page), and are comfortable on the command line in the first place. It’s even easier with a helper program like Kgpg or GnuPG. Here are some helpful hints if you want to give the command line version a shot (note this is for linux):

Windows users can check out

#to create a new key
gpg –gen-key

#to encrypt a message
gpg –recipient recipient –armor –encrypt file

#to decrypt a message
gpg –decrypt file

#to export public key (ascii)
gpg –armor –export name

#to export public key (ascii) to file
gpg –armor –output file –export name

#list public keys
gpg –list-keys

#import a public key
gpg –import file

A good guide can be found in the Ubuntu community documentation


xclip – interface to X clipboard

I recently discovered this handy utility called xclip which is command line interface to X selections (clipboard) .

see xclip man page


uptime | xclip

Put your uptime in the X selection. Then middle click in an X application to paste.

xclip -loops 10 -verbose /etc/motd

Exit after /etc/motd (message of the day) has been pasted 10 times. Show how many selection requests (pastes) have been processed.

xclip -o > helloworld.c

Put the contents of the selection into a file.


Note: make sure you are using alias xclip=”xclip -selection c” otherwise you can’t just use to CTRL+v to paste it back in a different place.

Preparing Debian Squeeze for Android development

Today I am going to discuss how to set up the Eclipse IDE with the Android SDK  for Android development on Debian squeeze.

To begin make sure you have the Java Development Kit  installed. I usually use sun’s Java but apparently openjdk works just as well although its not officially supported for android development. There are a few steps to go through but the commands  below will make it quick.

Step 1: Install Java

To install suns Java make sure you have edited your sources list to include the non-free repository . In order  to do this open a terminal  login as root . I will use “as root” to denote where root is required. To login as root use


then enter your root password.

To return to normal user mode type exit

To begin

nano  /etc/apt/sources.list  as root

add non-free beside main in your main source line

deb stable main contrib non-free

save the file and do an apt-get update as root

now do  apt-get install sun-java6-jdk as root

choose yes to install and accept the agreement

Java should now be installed you can test by running javac in a terminal.

Step 2: Install Eclipse

Next , we must download eclipse from

I use the classic version but any will do . For this tutorial I will be using the helios build for 64 bit architectures but its the same instructions for 32 bit ones.

download the build for you architecture and extract it when done using.

tar -xf eclipse-SDK-6.2-linux-gtk-x86_64.tar.gz

then move it to the /opt directory with the following command

mv ~/eclipse /opt as root

Step 3: Download the Android SDK

Next download the Android SDK from

once downloaded extract in the same way as we did with eclipse

tar -xf android-sdk_r11-linux_x86.tgz

then move it to the /opt directory  like so

mv android-sdk-linux_x86/ /opt as root

you should now have both the Android SDK and Eclipse in the opt directory now

the next step is to add the android developer toolkit to eclipse

Step 4: ADT Plugin

Start Eclipse, ( /opt/eclipse/eclipse) then select Help > Install New Software….
Click Add, in the top-right corner.
In the Add Repository dialog that appears, enter “ADT Plugin” for the Name and the following URL for the Location:

Add ADT Repository

Click OK. Note: If you have trouble acquiring the plugin, try using “http” in the Location URL, instead of “https” (https is preferred for security reasons).
In the Available Software dialog, select the checkbox next to Developer Tools and click Next. In the next window, you’ll see a list of the tools to be downloaded. Click Next. Read and accept the license agreements, then click Finish.Note: If you get a security warning saying that the authenticity or validity of the software can’t be established, click OK. When the installation completes, restart Eclipse.

Next in a terminal type


This will bring up the AVD and SDK manager  go to the available Packages in the side bar and select the API versions you wish. I usually select all of them to test against different revisions of the API. Proceed to install the selected packages  which can take a long time depending on how many you have selected and you connection speed.

Step 5: Set up a virtual device

Once that’s completed we need to make a virtual device to develop our programs on.

In Eclipse go to Window>Android SDK and AVD Manager and select new , fill out the details as required and click create.

Android Virtual Device

NOTE: it’s a good idea to make several AVD’s against the various API’s so you can thoroughly test your device.

You can now create a new android project by opening eclipse and selecting File>New>Other>Android>Android Project

(Optional )Step 6: Setting up a physical device

All credit for this section goes to unforgivin512


On the android developers website the guide for setting up a device under Ubuntu says to create the file “/etc/udev/rules.d/51-android.rules” , this does not work in the case of Debian. What you have to do in this case is

nano /lib/udev/rules.d/91-permissions.rules as root

Find the text similar to this

# usbfs-like devices SUBSYSTEM==”usb”, ENV{DEVTYPE}==”usb_device”, \ MODE=”0664″

Then change the mode to 0666 like below

# usbfs-like devices SUBSYSTEM==”usb”, ENV{DEVTYPE}==”usb_device”, \ MODE=”0666

This allows adb to work, however we still need to set up the device so it can be recognized. We need to create the file

nano /etc/udev/rules.d/99-android.rules as root

and enter

SUBSYSTEM==”usb”, ENV{DEVTYPE}==”usb_device”, ATTRS{idVendor}==”0bb4″, MODE=”0666″

NOTE: “0bb4” in this case is your vendors model (HTC in my case).

A full listing can be found here

Save the file and then restart udev as root /super user

/etc/init.d/udev restart as root

Connect the phone via USB and it should be detected when you compile and run a project.

That concludes this tutorial for today.

Fix Android Console Error: requires .class compatibility error

I recently ran into this error when migrating between versions of eclipse (due to a reinstall ), specifically from helios to indigo builds. The problem occurs due to the project being compiled against a particular Java version specified in the eclipse settings. Then when using a newer version of eclipse one will get a . class compatibility error complaining .

The error message states to select “fix project in android tools” (access by right clicking on the project folder). This did not work for me however.

I checked the Java bytecode format in “Window/Preferences”, “Java/Compiler/Compiler Compliance Level” to make sure version 1.6 was set (the version I was building against). This also did not solve the problem.

I eventually solved the problem by rebuilding the project