示例#1
0
	async generateMasterKeyAndEnableEncryption(password) {
		let masterKey = await this.generateMasterKey(password);
		masterKey = await MasterKey.save(masterKey);
		await this.enableEncryption(masterKey, password);
		await this.loadMasterKeysFromSettings();
		return masterKey;
	}
示例#2
0
async function loadEncryptionMasterKey(id = null, useExisting = false) {
	const service = encryptionService(id);

	let masterKey = null;

	if (!useExisting) { // Create it
		masterKey = await service.generateMasterKey('123456');
		masterKey = await MasterKey.save(masterKey);
	} else { // Use the one already available
		materKey = await MasterKey.all();
		if (!materKey.length) throw new Error('No mater key available');
		masterKey = materKey[0];
	}

	await service.loadMasterKey(masterKey, '123456', true);

	return masterKey;
}