Closed albert0m closed 5 years ago
Hello!
You can encrypt using BaseGsonConverter.class
or PreferenceFunction.
public class BaseGsonConverter<T> extends PreferenceTypeConverter<T> {
private final Gson gson;
/**
* default constructor will be called by PreferenceRoom
*/
public BaseGsonConverter(Class<T> clazz) {
super(clazz);
this.gson = new Gson();
}
@Override
public String convertObject(T object) {
return SecurityUtils.encrypt(gson.toJson(object)); // added encrypt logic
}
@Override
public T convertType(String string) {
return gson.fromJson(SecurityUtils.decrypt(string), clazz); // added decrpyt logic
}
}
But there are no way of encrypting the whole entity using annotation or function yet. I will consider the best way to encrypt functions on the next version. Thank you for your issue!
@marconealberto
It's implemented encrypt & decrypt automatically using @EncryptEntity annotation at version 1.1.6
.
It is based on AES128 encryption. You can reference demo-project.
Thank you!
I have a class like this:
I need to encrypt MyClass. How can I do that?