المجلدات وأسماء حزم dart واستيراداتها: siro_rider → intaleq_rider siro_driver → intaleq_driver siro_admin → intaleq_admin siro_service → intaleq_service شمل ذلك `name:` في كل pubspec وكل `package:siro_*` في الاستيرادات (115 ملفاً في rider وحده)، وإشارات أسماء المجلدات في docs/ وتعليق في backend/Admin/notifications/broadcast.php. لم تبقَ إشارة واحدة (تحقّقت). + ضُمّت حزم get و get_storage داخل intaleq_driver/packages/ وحُوّلت مساراتها الثلاثة من `../../Intaleq/packages/*` إلى `./packages/*`. كانت تُحل عرضاً إلى مجلد App/Intaleq القديم المجاور — تبعية خارج المستودع تنكسر بأول نقل. لم يبقَ في أي تطبيق تبعية مسار خارج الشجرة. ⚠️ لم تُمسّ بعد: هويات المتاجر (applicationId · PRODUCT_BUNDLE_IDENTIFIER · shorebird app_id) ولا الألوان ولا النصوص المرئية ولا النطاقات — كل منها كوميت منفصل، والهويات تحتاج قرار المالك. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
78 lines
2.3 KiB
Dart
78 lines
2.3 KiB
Dart
import 'package:encrypt/encrypt.dart' as encrypt;
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:secure_string_operations/secure_string_operations.dart';
|
|
|
|
import '../../constant/char_map.dart';
|
|
import '../../env/env.dart';
|
|
|
|
class EncryptionHelper {
|
|
static EncryptionHelper? _instance;
|
|
|
|
late final encrypt.Key key;
|
|
late final encrypt.IV iv;
|
|
|
|
EncryptionHelper._(this.key, this.iv);
|
|
static EncryptionHelper get instance {
|
|
if (_instance == null) {
|
|
throw Exception(
|
|
"EncryptionHelper is not initialized. Call `await EncryptionHelper.initialize()` in main.");
|
|
}
|
|
return _instance!;
|
|
}
|
|
|
|
/// Initializes and stores the instance globally
|
|
static Future<void> initialize() async {
|
|
if (_instance != null) {
|
|
debugPrint("EncryptionHelper is already initialized.");
|
|
return; // Prevent re-initialization
|
|
}
|
|
debugPrint("Initializing EncryptionHelper...");
|
|
var keyOfApp = r(Env.keyOfApp).toString().split(Env.addd)[0];
|
|
// Log.print('keyOfApp: ${keyOfApp}');
|
|
var initializationVector =
|
|
r(Env.initializationVector).toString().split(Env.addd)[0];
|
|
// Log.print('initializationVector: ${initializationVector}');
|
|
|
|
// Set the global instance
|
|
_instance = EncryptionHelper._(
|
|
encrypt.Key.fromUtf8(keyOfApp),
|
|
encrypt.IV.fromUtf8(initializationVector),
|
|
);
|
|
debugPrint("EncryptionHelper initialized successfully.");
|
|
}
|
|
|
|
/// Encrypts a string
|
|
String encryptData(String plainText) {
|
|
try {
|
|
final encrypter =
|
|
encrypt.Encrypter(encrypt.AES(key, mode: encrypt.AESMode.cbc));
|
|
final encrypted = encrypter.encrypt(plainText, iv: iv);
|
|
return encrypted.base64;
|
|
} catch (e) {
|
|
debugPrint('Encryption Error: $e');
|
|
return '';
|
|
}
|
|
}
|
|
|
|
/// Decrypts a string
|
|
String decryptData(String encryptedText) {
|
|
try {
|
|
final encrypter =
|
|
encrypt.Encrypter(encrypt.AES(key, mode: encrypt.AESMode.cbc));
|
|
final encrypted = encrypt.Encrypted.fromBase64(encryptedText);
|
|
return encrypter.decrypt(encrypted, iv: iv);
|
|
} catch (e) {
|
|
debugPrint('Decryption Error: $e');
|
|
return '';
|
|
}
|
|
}
|
|
}
|
|
|
|
r(String string) {
|
|
return X.r(X.r(X.r(string, cn), cC), cs).toString();
|
|
}
|
|
|
|
c(String string) {
|
|
return X.c(X.c(X.c(string, cn), cC), cs).toString();
|
|
}
|