> ## Documentation Index
> Fetch the complete documentation index at: https://lousho.com/llms.txt
> Use this file to discover all available pages before exploring further.

# وظائف مساعدة

> وظائف مساعدة داعمة مصدَّرة من جذر الحزمة: التشفير والتجزئة (hashing)، وتخزين ملفات المرفقات. لا تحتاج إلى أي منها لبناء وكيل؛ فهي موجودة لخدمة التطبيقات المحيطة به.

## التشفير والتجزئة

```ts theme={null}
import { EncryptionUtils, sha256 } from '@lousho/build-ai-agent';

const encryption = new EncryptionUtils('your-secret-key');
const encrypted = await encryption.encrypt('sensitive data'); // fresh random salt every call
const decrypted = await encryption.decrypt(encrypted);        // throws DecryptionError on tampering

const hash = await sha256('password', 'salt');
```

`encrypt()` تولّد ملحًا (salt) عشوائيًا في كل استدعاء، ولذلك لا يمكن فك تشفير
النص المشفَّر الذي كتبته الإصدارات السابقة لهذا التغيير ويجب إعادة تشفيره (راجع
[CHANGELOG](/changelog)).

## تخزين الملفات

`StorageService` يحفظ ملفات مستخدم واحد تحت مجلد مسمّى. تُحقن الوحدتان `fs`
و`path` محوِّلين (adapters)، ووحدات Node تستوفيهما
كما هي. وهو أيضًا ما يكتب عبره `StorageServiceApprovalStore`
و`LocalStorageCheckpointStore`.

```ts theme={null}
import { StorageService } from '@lousho/build-ai-agent';
import * as fs from 'node:fs';
import * as path from 'node:path';

// fs/path are injected as adapters; the Node modules satisfy them as-is.
const storage = new StorageService('user-123', 'attachments', fs, path);

await storage.saveAttachment(file, 'document.pdf');
const buffer = storage.readAttachment('document.pdf');
storage.deleteAttachment('document.pdf');
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.