From 05639b163a20d942c2be6d06a47d8cf74e57e90d Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Thu, 26 Feb 2026 19:02:42 +0800 Subject: [PATCH] New lockData function --- src/utils/functions/index.ts | 26 ++++++++++++++------------ src/utils/functions/lockData.ts | 11 +++++++++++ 2 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 src/utils/functions/lockData.ts diff --git a/src/utils/functions/index.ts b/src/utils/functions/index.ts index aad7471..a0a01fd 100644 --- a/src/utils/functions/index.ts +++ b/src/utils/functions/index.ts @@ -1,12 +1,14 @@ -export { default as checkConnection } from './checkConnection.ts'; -export { default as createPdfElectrical } from './createPdfElectrical.ts'; -export { default as createPdfOccupancy } from './createPdfOccupancy.ts'; -export { default as getApi } from './getApi.ts'; -export { default as getApiMulti } from './getApiMulti.ts'; -export { default as postApi } from './postApi.ts'; -export { default as statusPopsApi } from './statusPopsApi.ts'; -export { default as voidPopsApi } from './voidPopsApi.ts'; -export { default as securePassword } from './securePassword.ts'; -export { default as saveNewName } from './saveNewName.ts'; -export { default as saveNewPassword } from './saveNewPassword.ts'; -export { default as getDateTime } from './getDateTime.ts'; +export { default as checkConnection } from './checkConnection.ts' +export { default as createPdfElectrical } from './createPdfElectrical.ts' +export { default as createPdfOccupancy } from './createPdfOccupancy.ts' +export { default as getApi } from './getApi.ts' +export { default as getApiMulti } from './getApiMulti.ts' +export { default as postApi } from './postApi.ts' +export { default as statusPopsApi } from './statusPopsApi.ts' +export { default as voidPopsApi } from './voidPopsApi.ts' +export { default as securePassword } from './securePassword.ts' +export { default as saveNewName } from './saveNewName.ts' +export { default as saveNewPassword } from './saveNewPassword.ts' +export { default as getDateTime } from './getDateTime.ts' +export { default as deleteApi } from './deleteApi.ts' +export { default as lockData } from './lockData.ts' diff --git a/src/utils/functions/lockData.ts b/src/utils/functions/lockData.ts new file mode 100644 index 0000000..bdb3308 --- /dev/null +++ b/src/utils/functions/lockData.ts @@ -0,0 +1,11 @@ +import XChaCha20 from '@rabbit-company/xchacha20' + +export default async (text: string) => { + const SECRET_KEY = import.meta.env.VITE_SECRET_KEY + try { + const enc = XChaCha20.encrypt(text, SECRET_KEY) + return enc + } catch { + return '' + } +}