Fix decode feature in the app (MUST BE CHECKED)
This commit is contained in:
parent
1cb7c03d63
commit
cb428937d4
@ -73,10 +73,12 @@ public class DataCrypter {
|
|||||||
IvParameterSpec ivParameterSpec = new IvParameterSpec(context.getString(R.string.ivKey).getBytes("UTF-8"));
|
IvParameterSpec ivParameterSpec = new IvParameterSpec(context.getString(R.string.ivKey).getBytes("UTF-8"));
|
||||||
|
|
||||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
|
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
|
||||||
cipher.init(Cipher.ENCRYPT_MODE, aesKey, ivParameterSpec);
|
cipher.init(Cipher.DECRYPT_MODE, aesKey, ivParameterSpec);
|
||||||
|
|
||||||
byte[] dataBytes = Base64.decode(data, Base64.DEFAULT);
|
byte[] decryptedBytes = cipher.doFinal(data.getBytes("UTF-8"));
|
||||||
decryptedData = new String(dataBytes, StandardCharsets.UTF_8);
|
|
||||||
|
//byte[] dataBytes = Base64.decode(data, Base64.DEFAULT);
|
||||||
|
decryptedData = new String(decryptedBytes, StandardCharsets.UTF_8);
|
||||||
|
|
||||||
} catch(NoSuchPaddingException | NoSuchAlgorithmException
|
} catch(NoSuchPaddingException | NoSuchAlgorithmException
|
||||||
| InvalidKeyException | UnsupportedEncodingException
|
| InvalidKeyException | UnsupportedEncodingException
|
||||||
|
Loading…
Reference in New Issue
Block a user