Code example for PBEParameterSpec

0
            final byte[] bytes = value!=null ? Base64Coder.decode(value) : new byte[0];
            SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
            SecretKey key = keyFactory.generateSecret(new PBEKeySpec(secret.toCharArray()));
            Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES");
             
            pbeCipher.init(Cipher.DECRYPT_MODE, key, new PBEParameterSpec(getSalt(), 20));
            return new String(pbeCipher.doFinal(bytes),UTF8);
        } catch(Exception e) {
            throw new RuntimeException(e);
        } 
    } 
     
    private byte[] getSalt() throws UnsupportedEncodingException { 
    	return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID).getBytes(UTF8);
    } 
}