Files
JRedisDesktop/electron/main/credential.ts
T
Jokul bdcf4fe299 refactor: restructure project layout
- 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/
2026-07-04 21:12:50 +08:00

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'))
}