Java tutorial
//package com.java2s; import android.content.Context; import java.security.Key; import java.security.SecureRandom; import javax.crypto.Cipher; import javax.crypto.KeyGenerator; public class Main { private static Key key = null; private static byte[] getDesCode(Context mContext, byte[] byteD) { Cipher cipher; byte[] byteFina = null; try { cipher = Cipher.getInstance("DES"); cipher.init(Cipher.DECRYPT_MODE, getKey(mContext)); byteFina = cipher.doFinal(byteD); } catch (Exception e) { e.printStackTrace(); } finally { cipher = null; } return byteFina; } private static Key getKey(Context mContext) { if (key == null) { try { KeyGenerator _generator = KeyGenerator.getInstance("DES"); _generator.init(new SecureRandom(mContext.getPackageName().getBytes())); key = _generator.generateKey(); _generator = null; } catch (Exception e) { e.printStackTrace(); } } return key; } }