Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import javax.crypto.Cipher;

import javax.crypto.spec.SecretKeySpec;
import android.util.Base64;

public class Main {
    public static String decryptData(String encryptBase64Data, String keyBase64) {
        SecretKeySpec key = new SecretKeySpec(Base64.decode(keyBase64, Base64.DEFAULT), "DES");
        Cipher decipher = null;
        try {
            decipher = Cipher.getInstance("DES");
            decipher.init(Cipher.DECRYPT_MODE, key);
            byte[] encryptData = Base64.decode(encryptBase64Data, Base64.DEFAULT);
            return new String(decipher.doFinal(encryptData), "UTF8");
        } catch (Exception e) {
        }
        return null;
    }
}