in app/src/main/java/com/epam/securestorage/providers/cipher/CipherEncryptionProvider.java [283:309]
public void save(@NonNull String key, @NonNull String value) {
if (key == null || value == null || key.isEmpty() || value.isEmpty()) {
if (callback != null) {
callback.onError(SAVE, new SecureStorageException("Key or Value can't be NULL"));
}
return;
}
key = generateKeyWithPrefix(key);
try {
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
putPref(I_VECTOR + key, Arrays.toString(cipher.getIV()));
byte[] encryption = cipher.doFinal(value.getBytes(StandardCharsets.UTF_8));
String encryptedBase64Encoded = Base64.encodeToString(encryption, Base64.DEFAULT);
putPref(key, encryptedBase64Encoded);
if (callback != null) {
callback.onComplete(SAVE);
}
} catch (InvalidKeyException | BadPaddingException | IllegalBlockSizeException e) {
e.printStackTrace();
if (callback != null) {
callback.onError(SAVE, e);
}
}
}