bdcf4fe299
- Move main process to electron/main/ - Move preload to electron/preload/ - Add shared types in electron/shared/ - Split redis-service into modular redis/ directory - Flatten renderer to src/ (remove src/renderer/ nesting) - Update electron.vite.config.ts paths - Update tsconfig paths - Output to electron-dist/
17 lines
505 B
TypeScript
17 lines
505 B
TypeScript
// src/main/credential.ts
|
|
import { safeStorage } from 'electron'
|
|
|
|
export function encrypt(text: string): string {
|
|
if (!safeStorage.isEncryptionAvailable()) {
|
|
return Buffer.from(text).toString('base64')
|
|
}
|
|
return safeStorage.encryptString(text).toString('base64')
|
|
}
|
|
|
|
export function decrypt(encoded: string): string {
|
|
if (!safeStorage.isEncryptionAvailable()) {
|
|
return Buffer.from(encoded, 'base64').toString('utf-8')
|
|
}
|
|
return safeStorage.decryptString(Buffer.from(encoded, 'base64'))
|
|
}
|