· 5 years ago · Jul 29, 2020, 04:44 AM
1public static String decryptBase64(String codedtext, String keyString) throws Exception {
2 final MessageDigest md = MessageDigest.getInstance("md5");
3 final byte[] digestOfPassword = md.digest(keyString.getBytes("utf-8"));
4 final byte[] keyBytes = Arrays.copyOf(digestOfPassword, 24);
5 for (int j = 0, k = 16; j < 8;) {
6 keyBytes[k++] = keyBytes[j++];
7 }
8
9 final SecretKey key = new SecretKeySpec(keyBytes, "DESede");
10 final IvParameterSpec iv = new IvParameterSpec(new byte[8]);
11 final Cipher cipher = Cipher.getInstance("DESede/ECB/PKCS5Padding");
12 cipher.init(Cipher.DECRYPT_MODE, key);
13
14 final byte[] plainTextBytes =new Base64().decode(codedtext);
15 final byte[] cipherText = cipher.doFinal(plainTextBytes);
16 final String decryptedCipherText = new String(cipherText,"utf-8"); ;
17 return decryptedCipherText;
18 }
19
20encryptedstring = "CftozpspcVnys9xfQ%252FH3wsus2Fr3rX5xBwdW9Fhkehf6MAhT7vDhGlXJS93r6shQ4xym5rQ%252F6MeiIMUNWCEaoQ%253D%253D";