Fix decode feature in the app (MUST BE CHECKED)

This commit is contained in:
Tanguy Herbron 2018-10-02 15:36:56 +02:00 committed by GitHub
parent 1cb7c03d63
commit cb428937d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,10 +73,12 @@ public class DataCrypter {
IvParameterSpec ivParameterSpec = new IvParameterSpec(context.getString(R.string.ivKey).getBytes("UTF-8"));
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
cipher.init(Cipher.ENCRYPT_MODE, aesKey, ivParameterSpec);
cipher.init(Cipher.DECRYPT_MODE, aesKey, ivParameterSpec);
byte[] decryptedBytes = cipher.doFinal(data.getBytes("UTF-8"));
byte[] dataBytes = Base64.decode(data, Base64.DEFAULT);
decryptedData = new String(dataBytes, StandardCharsets.UTF_8);
//byte[] dataBytes = Base64.decode(data, Base64.DEFAULT);
decryptedData = new String(decryptedBytes, StandardCharsets.UTF_8);
} catch(NoSuchPaddingException | NoSuchAlgorithmException
| InvalidKeyException | UnsupportedEncodingException