update
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
// 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'))
|
||||
}
|
||||
Reference in New Issue
Block a user