Download

Adding encryption to Android App

Hello everyone,

I’m extremely new to Android development but thought I would give it a go. So far I’m enjoying it although I admit there is a bit of a learning curve to start with.

Anyway, I wanted to add some encryption to the app I’m developing but I’m having trouble getting started. In my code I’ve done something similar to this:

Code:


import javax.crypto.*;

public class Connection {
    private KeyGenerator _keygen = null;
    
    public Connection() {
        this._keygen = KeyGenerator.getInstance("AES");
    }
}

When I do this Android Studio shows up an error with this line of code (call to KeyGenerator.getInstance) - “Unhandled exception: java.security.NoSuchAlgorithmException”

I have tried putting this line of code in a try/catch block so that I can compile the code although it doesn’t execute properly…

Judging by the error, I am guessing that for some reason Android Studio can’t find an implementation of this class/method… What am I doing wrong?

Cheers,