add safe storage util

This commit is contained in:
Abhinav 2022-07-11 01:59:30 +05:30
parent 8653867178
commit 171412575e

12
src/utils/safeStorage.ts Normal file
View file

@ -0,0 +1,12 @@
import { safeStorage } from 'electron';
import { safeStorageStore } from '../services/store';
export function setEncryptionKey(encryptionKey: string) {
const buffer = safeStorage.encryptString(encryptionKey);
safeStorageStore.set('encryptionKey', buffer.toString('base64'));
}
export function getEncryptionKey() {
const bufferString = safeStorageStore.get('encryptionKey');
return safeStorage.decryptString(Buffer.from(bufferString, 'base64'));
}