in app/src/main/java/com/epam/securestorage/providers/themis/ThemisEncryptionProvider.java [53:81]
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;
}
if (key != null && value != null) {
key = generateKeyWithPrefix(key);
try {
SecureCell sc = new SecureCell(key.getBytes(StandardCharsets.UTF_8), MODE_SEAL);
SecureCellData protectedData = sc.protect(key.getBytes(StandardCharsets.UTF_8), value.getBytes(StandardCharsets.UTF_8));
String encodedString = Base64.encodeToString(protectedData.getProtectedData(), Base64.NO_WRAP);
this.preferences.edit().putString(key, encodedString).apply();
if (callback != null) {
callback.onComplete(SAVE);
}
} catch (InvalidArgumentException | NullArgumentException | SecureCellException e) {
e.printStackTrace();
if (callback != null) {
callback.onError(SAVE, e);
}
}
}
}