Kushal Das

FOSS and life. Kushal Das talks here.

kushal76uaid62oup5774umh654scnu5dwzh4u2534qxhcbi4wbab3ad.onion

Running Ubiquity controller on a Raspberry Pi

I got a few new Raspberry Pi(s) with 4GB RAM. I used them as a full scale desktop for some time, and was happy with the performance.

I used to run the Ubiquity controller for the home network in a full-size desktop. Looking at the performance of this RPI model, I thought of moving it out to this machine.

I am using Debian Buster based image here. The first step is to create a new source list file at /etc/apt/sources.list.d/ubnt.list

deb https://www.ubnt.com/downloads/unifi/debian unifi5 ubiquiti

Then, install the software, and also openjdk-8-jdk, remember that the controller works only with that particular version of Java.

apt-get update
apt-get install openjdk-8-jdk unifi

We will also have to update the JAVE_HOME variable in /usr/lib/unifi/bin/unifi.init file.

JAVA_HOME=/usr/lib/jvm/java-8-openjdk-armhf/

Then, we can enable and start the service.

systemctl enable unifi
systemctl start unifi

Getting md5

Want to get MD5 ? Examples are in Python and Java

In Python: >>> import md5 >>> print md5.md5("kushal").hexdigest() '6ec44a1207a3d9506418c034679087b6' Easy isn't it !!

Now let us do the same in JAVA:

import java.security.MessageDigest;
import java.lang.String;

class MD5 {
    public static void main(String args[]) {
        try {
            MessageDigest digest = MessageDigest.getInstance("MD5");
            digest.update("kushal".getBytes());
            System.out.println(byteArrayToHexString(digest.digest()));
        }
        catch (Exception e){
            e.printStackTrace();
        }
        }

    public static String byteArrayToHexString(byte in[]) {
        byte ch = 0x00;
        int i = 0; 
        if (in == null || in.length <= 0)
            return null;
        String pseudo[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"};
        StringBuffer out = new StringBuffer(in.length * 2);
    
        while (i < in.length) {
            ch = (byte) (in[i] & 0xF0); 
            ch = (byte) (ch >>> 4);
            ch = (byte) (ch & 0x0F);    
            out.append(pseudo[ (int) ch]); 
            ch = (byte) (in[i] & 0x0F); 
            out.append(pseudo[ (int) ch]); 
            i++;
        }
        String rslt = new String(out);
        return rslt;
    }    
}

I found that code on byteArrayToHexString somewhere in the net.

Update: As ignacio pointed in the comments that the md5 module is deprecated in Python 2.5, we have to use hashlib module instead. >>> import hashlib >>> h = hashlib.md5() >>> h.update('kushal') >>> h.hexdigest() '6ec44a1207a3d9506418c034679087b6'