in app/src/main/java/com/epam/securestorage/providers/themis/ThemisEncryptionProvider.java [85:126]
public String get(@NonNull String key) {
if (key == null || key.isEmpty()) {
if (callback != null) {
callback.onError(GET, new SecureStorageException("Key or Value can't be NULL"));
}
return null;
}
try {
key = generateKeyWithPrefix(key);
String encodedString = preferences.getString(key, null);
String decryptedData;
if (encodedString != null) {
byte[] decodedString = Base64.decode(encodedString, Base64.NO_WRAP);
SecureCell sc = new SecureCell(key.getBytes(StandardCharsets.UTF_8), MODE_SEAL);
SecureCellData encryptedData = new SecureCellData(decodedString, null);
byte[] unprotectedData = sc.unprotect(key.getBytes(StandardCharsets.UTF_8), encryptedData);
decryptedData = new String(unprotectedData, StandardCharsets.UTF_8);
if (callback != null) {
callback.onComplete(GET);
}
return decryptedData;
} else {
if (callback != null) {
callback.onError(GET, new SecureStorageException("No Such Value"));
}
return null;
}
} catch (InvalidArgumentException | NullArgumentException | SecureCellException e) {
e.printStackTrace();
if (callback != null) {
callback.onError(GET, e);
}
}
return null;
}