Coder Social home page Coder Social logo

kishandonga / easyprefs Goto Github PK

View Code? Open in Web Editor NEW
10.0 10.0 4.0 273 KB

EasyPrefs is a wrapper on the android shared preferences, also it will need only one-time initialization and used in the whole project without context, it supports encryption and decryption with extended APIs.

License: MIT License

Kotlin 91.08% Java 8.92%
android android-library androidlibrary easy-to-use encrypted-preferences encryptedpreferences encryptedsharedpreferences preferences preferences-api sharedpreferences sharedpreferences-editor tested

easyprefs's Issues

Remove

Hi , thank you for your Lib
I can write and read securely() form but I couldn't remove any Key!

Prefs.remove(this)
                        .key("$i")
                        .commit()

Could not find com.github.kishandonga:EasyPrefs:1.1.

Sorry I'm new to Android development.

In the build.gradle(Project) I have added this:

repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
    }

In the build.gradle(App) I added this:

dependencies {
  ...
    implementation 'com.github.kishandonga:EasyPrefs:1.1'
}

When I rebuild the project I get this:

Could not find com.github.kishandonga:EasyPrefs:1.1.
Required by:
project :app

Isn't this like CocoaPods in iOS where the libs get pulled automatically? Do I still have to copy and paste the lib by hand into my project? Is there a better way? Thanks

Read value from file

This code incorrect when get file from preference

    override fun readOn(
        context: Context,
        fileName: String,
        encType: Encryption
    ): Read {
        return ReadImpl(
            PrefProvider.getPref(context, **getFileName(context)**, encType),
            encType
        )
    }

Caused by: javax.crypto.AEADBadTagException

I got crashed when read
if (Prefs.securely().read().content("IsLoginEnable", false)) {

Error is

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:618)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103) 
Caused by: javax.crypto.AEADBadTagException
at android.security.keystore2.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:632)
at javax.crypto.Cipher.doFinal(Cipher.java:2114)
at com.google.crypto.tink.integration.android.AndroidKeystoreAesGcm.decryptInternal(AndroidKeystoreAesGcm.java:118)
at com.google.crypto.tink.integration.android.AndroidKeystoreAesGcm.decrypt(AndroidKeystoreAesGcm.java:101)
at com.google.crypto.tink.KeysetHandle.decrypt(KeysetHandle.java:919)
at com.google.crypto.tink.KeysetHandle.readWithAssociatedData(KeysetHandle.java:804)
at com.google.crypto.tink.KeysetHandle.read(KeysetHandle.java:785)
at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.readMasterkeyDecryptAndParseKeyset(AndroidKeysetManager.java:381)
at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.build(AndroidKeysetManager.java:297)
at androidx.security.crypto.EncryptedSharedPreferences.create(EncryptedSharedPreferences.java:169)
at androidx.security.crypto.EncryptedSharedPreferences.create(EncryptedSharedPreferences.java:130)
at io.easyprefs.secure.EncryptedPref.getPreferences(EncryptedPref.kt:28)
at io.easyprefs.impl.PrefProvider.getPref(PrefProvider.kt:22)
at io.easyprefs.impl.EasyPrefImpl.read(EasyPrefImpl.kt:34)
at io.easyprefs.impl.SecurePrefImpl.read(SecurePrefImpl.kt:57)
at io.easyprefs.impl.SecurePrefImpl.read(SecurePrefImpl.kt:44)
at com.demo.mob.ui.login.LoginFragment.showBiometricLoginOption(LoginFragment.kt:155)
at com.demo.mob.ui.login.LoginFragment.setUpView(LoginFragment.kt:99)
at com.demo.mob.ui.login.LoginFragment.onCreateView(LoginFragment.kt:60)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:3114)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:557)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:272)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1943)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1839)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1782)
at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:565)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:230)
at android.os.Looper.loop(Looper.java:319)
at android.app.ActivityThread.main(ActivityThread.java:8906)
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103) 
Caused by: android.security.KeyStoreException: Signature/MAC verification failed (internal Keystore code: -30 message: system/security/keystore2/src/operation.rs:850: KeystoreOperation::finish

                                     Caused by:
                                         0: system/security/keystore2/src/operation.rs:426: Finish failed.
                                         1: Error::Km(r#VERIFICATION_FAILED)) (public error code: 10 internal Keystore code: -30)
                                     	at android.security.KeyStore2.getKeyStoreException(KeyStore2.java:435)
                                     	at android.security.KeyStoreOperation.handleExceptions(KeyStoreOperation.java:78)
                                     	at android.security.KeyStoreOperation.finish(KeyStoreOperation.java:128)
                                     	at android.security.keystore2.KeyStoreCryptoOperationChunkedStreamer$MainDataStream.finish(KeyStoreCryptoOperationChunkedStreamer.java:228)
                                     	at android.security.keystore2.KeyStoreCryptoOperationChunkedStreamer.doFinal(KeyStoreCryptoOperationChunkedStreamer.java:181)

10:42:17.584 AndroidRuntime E at android.security.keystore2.AndroidKeyStoreAuthenticatedAESCipherSpi$BufferAllOutputUntilDoFinalStreamer.doFinal(AndroidKeyStoreAuthenticatedAESCipherSpi.java:396)
at android.security.keystore2.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:624)
... 33 more

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.