Code example for PBEParameterSpec

0
        try { 
            final byte[] bytes = value != null ? Base64.decode(value, Base64.DEFAULT) : new byte[0];
            SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
            SecretKey key = keyFactory.generateSecret(new PBEKeySpec(SEKRIT));
            Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES");
            pbeCipher.init(Cipher.DECRYPT_MODE, key, new PBEParameterSpec(SALT, 20));
            return new String(pbeCipher.doFinal(bytes), UTF8);
 
        } catch (Exception e) {
            throw new RuntimeException(e);
        } 
    } 
 
    public class ObfuscatedEditor implements SharedPreferences.Editor {
        protected SharedPreferences.Editor delegate;
 
        private ObfuscatedEditor() { 
            this.delegate = ObfuscatedSharedPreferences.this.delegate.edit();
        } 
 
        @Override