- Minimum Android SDK: MBCommonKit requires a minimum API level of 19.
- Compile Android SDK: MBCommonKit requires you to compile against minimum API level 27.
This module contains a fascade implementation for the usage of the KeyStore
API, convient APIs for SharedPreferences
and
general utility methods.
Use the class Crypto
for encryption operations.
val alias = "my.crypto.alias"
val crypto = Crypto(context)
// Generate a new key for the alias if it does not exist.
if (!crypto.keyExists(alias)) {
crypto.generateKey(alias)
}
// Encrypt strings.
val encryptedText = crypto.encrypt(alias, "my_plain_text")
// Decrypt strings.
crypto.decrypt(alias, encryptedText)
You can use the convient implementations for the usage of SharedPreferences
.
val preferences = context.getSharedPreferences("my_preferences", Context.MODE_PRIVATE)
val simplePref: Preference<Boolean> = preferences.booleanPreference("key", false)
val prefValue = simplePref.get() // prefValue contains the default value "false"
simplePref.set(true)
val newPrefValue = simplePref.get() // newPrefValue now contains "true"
simplePref.observe(object : PreferenceObserver<Boolean> {
override fun onChanged(newValue: Boolean) {
// The preferences value changed.
// Stop observing.
simplePref.stopObserving(this)
}
}
Add the following maven url to your project build.gradle
:
allprojects {
repositories {
google()
jcenter()
maven {
url 'https://pkgs.dev.azure.com/daimler-ris/sdk/_packaging/release/maven/v1'
}
}
}
Add to your app's build.gradle
:
implementation "com.daimler.mm:MBCommonKit:$mb_common_kit_version"
We welcome any contributions. If you want to contribute to this project, please read the contributing guide.
Please read our Code of Conduct as it is our base for interaction.
This project is licensed under the MIT LICENSE.
Please visit https://mbition.io/en/home/index.html for information on the provider.
Notice: Before you use the program in productive use, please take all necessary precautions, e.g. testing and verifying the program with regard to your specific use. The program was tested solely for our own use cases, which might differ from yours.