Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Will it support encryption? #72

Closed
fly7632785 opened this issue Dec 14, 2017 · 6 comments
Closed

Will it support encryption? #72

fly7632785 opened this issue Dec 14, 2017 · 6 comments
Labels

Comments

@fly7632785
Copy link

fly7632785 commented Dec 14, 2017

Hi, this is a great open library
but, will it support encryption?
That must be better

@fly7632785 fly7632785 changed the title Does it support encryption? Will it support encryption? Dec 14, 2017
@chibatching
Copy link
Owner

I have no plan to support encryption.
But I used with other encryption library (https://github.com/gfx/Android-EncryptUtils) in production code.

Example

object EncryptedData : KotprefModel() {

    private val encryption = Encryption(Encryption.getDefaultCipher(), byteArrayOf(...))
    
    private var encryptedFoo by stringPref("")

    fun getFoo(): String =
            if (encryptedFoo.isEmpty()) {
                ""
            } else {
                encryption.decrypt(encryptedFoo)
            }

    fun setFoo(foo: String) {
        if (foo.isNotEmpty()) {
            encryptedFoo = encryption.encrypt(foo)
        }
    }
}

I think that you can use any other library you want.

@fly7632785
Copy link
Author

Thanks, I will look at it

@fly7632785
Copy link
Author

But, if I use this library to encrypt. How can I encrypt the Object, is there any interface to operate the gson string? Please and thank you

@fly7632785
Copy link
Author

And @chibatching
May I fork your library and add a encryption support?
Hope to communicate with you in the spect of tech

@chibatching
Copy link
Owner

chibatching commented Dec 20, 2017

Of course it's ok, but I will try to create interface to inject custom converter (e.g. #42) to Kotpref at next major version.
This may possibly cause stop developing and remove some optional support artifact (like gson, enum support) from this repo.

@fly7632785
Copy link
Author

Well, good
I've forked it
Kotpref
and make a support library of Encryption
KotprefEncryptSupport
Hope to get your suggestion about it.
And thank you,Your Kotpref is a good lib.
Custom converter is a good idea,
I will stay focused on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants