add safe storage util
This commit is contained in:
parent
8653867178
commit
171412575e
12
src/utils/safeStorage.ts
Normal file
12
src/utils/safeStorage.ts
Normal 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'));
|
||||
}
|
Loading…
Reference in a new issue