Seed External Encryption Key for Data at Rest Encryption

Last updated September 16, 2023 by Appdome

Use the following code to decide what will be the external seed for the key with Data at Rest encryption for iOS and Android.

Android

Call this function from any activity

private void sendSeedDataAtRestEvent(String secretSeed) {
      Intent intent = new Intent("SeedDataAtRest");
      Bundle bundle = new Bundle();
      bundle.putString("Seed", secretSeed); 
      intent.putExtras(bundle);
      sendBroadcast(intent);
}

iOS

Add this code snippet this from anywhere in the application

[[NSNotificationCenter defaultCenter] postNotificationName:@"SeedDataAtRest" object:nil userInfo: @{@"Seed": secretSeed}];

External Seed on Maui, Xamarin Apps

iOS

Open a Maui, Xamarin.Forms project in Visual Studio.

Open the file AppDelegate.cs. Under FinishedLaunching method add the following lines:

public const String secretSeed = "mySecretSeed";
NSNotificationCenter.DefaultCenter.PostNotificationName(
   (NSString)"SeedDataAtRest",
   null,
   new NSDictionary<NSString, NSObject>(new[] { new NSString("Seed") }, new NSString[] { new NSString(secretSeed) })
  );

Add a class variable to your app:

public const String secretSeed = "mySecretSeed";

Android

Using the following code to decide what will be the external seed for the key with Data at Rest encryption for Android. In the MainActivity.cs file, add the following method SendSeedDataAtRestEvent().

private void SendSeedDataAtRestEvent(String secretSeed)
{
Intent intent = new Intent("SeedDataAtRest");
Bundle bundle = new Bundle();
bundle.PutString("Seed", secretSeed);
intent.PutExtras(bundle);
SendBroadcast(intent);
}

Then add a call to this method from the protected override void OnCreate(Bundle savedInstanceState) method:

SendSeedDataAtRestEvent("mySecretSeed");

External Seed on Cordova Apps (iOS and Android)

  • Create a Cordova project
  • Add the project your app platform: Android and/or iOS
  • Add Cordova-plugin-broadcaster – Cordova Plugin which allows messages exchange between javascript (Android LocalBroadcastManager and iOS NSNotificationCenter) and native (and vice-versa).

Using the following code to decide what will be the external seed for the key with Data at Rest encryption for iOS and Android:

window.broadcaster.fireNativeEvent( "SeedDataAtRest", {Seed: "<a dictionary with the secret seed to send>"}, null);

External Seed on Swift Apps

Using the following code to decide what will be the external seed for the key with Data at Rest encryption for iOS:

NotificationCenter.default.post(name: NSNotification.Name("SeedDataAtRest"), object: nil, userInfo: ["Seed" : "mySecretSeed"] )

External Seed on Kotlin Apps

Using the following code to decide what will be the external seed for the key with Data at Rest encryption for iOS:

val intent = Intent("SeedDataAtRest")
val bundle = Bundle()
bundle.putString("Seed", "mySecretSeed")
intent.putExtras(bundle)
sendBroadcast(intent)

External Seed on React-Native Apps (iOS and Android)

  • For iOS – open the iOS project in Xcode (resides in IOS folder under the root directory of the project)
  • For Android- open the android project in Android Studio (it resides in the Android folder under the root directory).

Using the following code to decide what will be the external seed for the key with Data at Rest encryption for iOS and Android:

import {NativeModules} from 'react-native';
export function post_seed() {
    NativeModules.ADDevEvents.postDevEvent("SeedDataAtRest", {"Seed": "mySecretSeed"});
}

Related Articles:

How Do I Learn More?

The description above is designed to help you decide what will be the external seed for the key with Data at Rest encryption for iOS and Android. If you have any questions, please send them our way at support.appdome.com or via the chat window on the Appdome platform. 

Thank you!

Thanks for visiting Appdome! Our mission is to secure every app on the planet by making mobile app security easy. We hope we’re living up to the mission with your project.

Appdome

Want a Demo?

Mobile Data Encryption

AlanWe're here to help
We'll get back to you in 24 hours to schedule your demo.