· 7 years ago · Feb 14, 2018, 09:34 AM
1SharedPreferences preferences = getSharedPreferences("mypref", MODE_PRIVATE);
2id = preferences.getString("id", "");
3password=preferences.getString("password","");
4
5byte[] decodePassword;
6decodePassword= Base64.decode(password, Base64.DEFAULT);
7
8public static String dec(String input_text,String secret_key) {
9 try {
10 AlgorithmParameterSpec paramSpec = new IvParameterSpec(secret_key
11 .getBytes());
12 Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
13 SecretKeySpec key = new SecretKeySpec(secret_key.getBytes(), "AES");
14 cipher.init(Cipher.DECRYPT_MODE, key, paramSpec);
15 byte[] output = Base64.decodeBase64(input_text.getBytes());
16 byte[] decrypted = cipher.doFinal(output);
17 return new String(decrypted);
18 } catch (Exception e) {
19 e.printStackTrace();
20 return "";
21 }
22 }