Seed data is important to populate the database with initial values. In the context of Vaulteron, we need to generate a key pair and perform encryption using user credentials. This is how you create the seed data:
Prerequisites:
- The
cryptoManager
must be in thewindow
-object must be globally available (see filecryptoManager
). - Adjust the login password in the following code snippet as needed.
window.globalCryptoManager.createAsynchronousKeyPair().then(kp => {
let loginPW = "12345";
let userName = "Mako";
console.log(kp);
let result = "";
result += `public const string ${userName}PublicKey = @"${kp.publicKey}";`;
result += `public const string ${userName}PrivateKey = @"${kp.privateKey}";`;
window.globalCryptoManager.encryptUsingUserCredentials(kp.privateKey, loginPW).then(privKey => {
result += `public const string ${userName}EncryptedPrivateKey = @"${privKey}";`;
console.log(result);
});
});
By following these instructions, you can successfully set up the database, handle potential migration errors, and generate seed data for the Vaulteron client app built with React. This provides a solid foundation for building a secure and efficient platform for managing sensitive information.