Skip to content

MiHawk πŸ¦…πŸ‘οΈ is simple and secure πŸ”’ Android Library to store and retrieve pair of key-value data with encryption , internally it use jetpack DataStore Preferences πŸ’½ to store data.

Notifications You must be signed in to change notification settings

nedaluof/MiHawk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

41 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation






MiHawk

MiHawk πŸ¦…πŸ‘οΈ is simple and secure πŸ”’ Android Library to store and retrieve pair of key-value data with encryption , internally it use jetpack DataStore Preferences πŸ’½ to store data.

Usage

Dependency

//In build.gradle
allprojects {
  repositories {
     maven { url 'https://jitpack.io' }
  }
}

//Include the library in your build.gradle.YOUR_MODULE
dependencies {
   implementation 'com.github.nedaluof:MiHawk:1.2.2'
}

- Initialize MiHawk:

  /**
   * There are two ways to init MiHawk , in both MiHawk must initialized 
   * before any use of it else RuntimeException will be thrown
   * */
   MiHawk.init(context)
   //OR 
   MiHawk.Builder(context)
      .withPreferenceName("MI_HAWK_PREFS")
      .withLoggingEnabled(false)
      .withMiLogger(MiLogger Implementation)
      .withMiEncryption(MiEncryption Implementation)
      .withMiSerializer(MiSerializer Implementation)
      .build()

- Put data to MiHawk:

  MiHawk.put(key: String, value: T)

- Get data from MiHawk:

  • over result block "Higher-order function"
  MiHawk.get<T>(key: String, result: (T?) -> Unit)
  //OR with default value:
  MiHawk.get<T>(key: String, defaultValue: T,  result: (T?) -> Unit)
  • direct result
  MiHawk.get<T>(key: String) : T?
  //OR with default value:
  MiHawk.get<T>(key: String, defaultValue: T) : T? 

- Check if data exist in MiHawk by key:

  MiHawk.contains(key: String, result: (Boolean) -> Unit)

- Remove data from MiHawk:

  MiHawk.remove(key: String, result: (Boolean) -> Unit)

- Remove all saved data from MiHawk:

  MiHawk.deleteAll(result: (Boolean) -> Unit)


- Todos


  • Provide heavy unit test.
  • Provide simple UI that simulate the inputs to test.


License

Copyright 2021 Nedal Hasan ABDALLAH (NedaluOf)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an 
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the specific 
language governing permissions and limitations under the License.

~ Inspired from Hawk Library. ~

About

MiHawk πŸ¦…πŸ‘οΈ is simple and secure πŸ”’ Android Library to store and retrieve pair of key-value data with encryption , internally it use jetpack DataStore Preferences πŸ’½ to store data.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages