7/5/4
This commit is contained in:
@@ -1,21 +1,19 @@
|
||||
import 'package:encrypt/encrypt.dart' as encrypt;
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:encrypt/encrypt.dart' as encrypt;
|
||||
|
||||
//
|
||||
import 'dart:convert';
|
||||
import 'dart:math';
|
||||
import 'package:encrypt/encrypt.dart' as encrypt;
|
||||
import '../../constant/api_key.dart';
|
||||
|
||||
class KeyEncryption {
|
||||
static final _key = encrypt.Key.fromUtf8('mehmetDEV@2101'); // ضع مفتاحك هنا
|
||||
// استخدم مفتاح بطول 32 حرفًا
|
||||
static final _key = encrypt.Key.fromUtf8(AK.keyOfApp);
|
||||
static final _iv =
|
||||
encrypt.IV.fromLength(16); // توليد تهيئة عشوائية بطول 16 بايت
|
||||
|
||||
static String encryptKey(String key) {
|
||||
final iv = encrypt.IV.fromLength(16); // توليد تهيئة عشوائية
|
||||
final encrypter =
|
||||
encrypt.Encrypter(encrypt.AES(_key, mode: encrypt.AESMode.cbc));
|
||||
final encrypted = encrypter.encrypt(key, iv: iv);
|
||||
final result = iv.bytes + encrypted.bytes; // تضمين التهيئة مع النص المشفر
|
||||
final encrypted = encrypter.encrypt(key, iv: _iv);
|
||||
final result = _iv.bytes + encrypted.bytes; // تضمين التهيئة مع النص المشفر
|
||||
return base64Encode(result);
|
||||
}
|
||||
|
||||
@@ -29,55 +27,3 @@ class KeyEncryption {
|
||||
return encrypter.decrypt(encrypted, iv: iv);
|
||||
}
|
||||
}
|
||||
|
||||
// class KeyEncryption {
|
||||
// static final _key = encrypt.Key.fromUtf8('7'); // ضع مفتاحك هنا
|
||||
//
|
||||
// static String encryptKey(String key) {
|
||||
// final iv = encrypt.IV.fromLength(16); // توليد تهيئة عشوائية
|
||||
// final encrypter =
|
||||
// encrypt.Encrypter(encrypt.AES(_key, mode: encrypt.AESMode.cbc));
|
||||
// final encrypted = encrypter.encrypt(key, iv: iv);
|
||||
// final result = iv.bytes + encrypted.bytes; // تضمين التهيئة مع النص المشفر
|
||||
// return base64Encode(result);
|
||||
// }
|
||||
//
|
||||
// static String decryptKey(String encryptedKey) {
|
||||
// final decoded = base64Decode(encryptedKey);
|
||||
// final iv = encrypt.IV(decoded.sublist(0, 16)); // استخراج التهيئة
|
||||
// final encrypted =
|
||||
// encrypt.Encrypted(decoded.sublist(16)); // استخراج النص المشفر
|
||||
// final encrypter =
|
||||
// encrypt.Encrypter(encrypt.AES(_key, mode: encrypt.AESMode.cbc));
|
||||
// return encrypter.decrypt(encrypted, iv: iv);
|
||||
// }
|
||||
// }
|
||||
|
||||
// class KeyEncryption {
|
||||
// static final _key =
|
||||
// encrypt.Key.fromUtf8('32-character-key....'); // ضع مفتاحك هنا
|
||||
//
|
||||
// static String encryptKey(String key) {
|
||||
// final iv = encrypt.IV.fromLength(16); // توليد تهيئة عشوائية
|
||||
// final encrypter =
|
||||
// encrypt.Encrypter(encrypt.AES(_key, mode: encrypt.AESMode.cbc));
|
||||
// final encrypted = encrypter.encrypt(key, iv: iv);
|
||||
// final result = iv.bytes + encrypted.bytes; // تضمين التهيئة مع النص المشفر
|
||||
// return base64Encode(result);
|
||||
// }
|
||||
//
|
||||
// static Future<void> storeApiKeys(List<String> apiKeys) async {
|
||||
// final encryptedKeys = apiKeys.map((key) => encryptKey(key)).toList();
|
||||
// final response = await http.post(
|
||||
// Uri.parse('https://yourdomain.com/store_keys.php'),
|
||||
// body: jsonEncode({'keys': encryptedKeys}),
|
||||
// headers: {'Content-Type': 'application/json'},
|
||||
// );
|
||||
//
|
||||
// if (response.statusCode == 200) {
|
||||
// print('Keys stored successfully.');
|
||||
// } else {
|
||||
// print('Failed to store keys.');
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
67
lib/controller/functions/package_info.dart
Normal file
67
lib/controller/functions/package_info.dart
Normal file
@@ -0,0 +1,67 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:SEFER/constant/links.dart';
|
||||
import 'package:SEFER/controller/functions/crud.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import '../../constant/info.dart';
|
||||
|
||||
Future<void> checkForUpdate(BuildContext context) async {
|
||||
final packageInfo = await PackageInfo.fromPlatform();
|
||||
final currentVersion = packageInfo.buildNumber;
|
||||
print('currentVersion is : $currentVersion');
|
||||
// Fetch the latest version from your server
|
||||
String latestVersion = await getPackageInfo();
|
||||
|
||||
if (latestVersion.isNotEmpty && latestVersion != currentVersion) {
|
||||
showUpdateDialog(context);
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> getPackageInfo() async {
|
||||
final response = await CRUD().get(link: AppLink.packageInfo, payload: {
|
||||
"platform": Platform.isAndroid ? 'android' : 'ios',
|
||||
"appName": AppInformation.appName,
|
||||
});
|
||||
|
||||
if (response != 'failure') {
|
||||
return jsonDecode(response)['message'][0]['version'];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
void showUpdateDialog(BuildContext context) {
|
||||
final String storeUrl = Platform.isAndroid
|
||||
? 'https://play.google.com/store/apps/details?id=com.sefer_driver'
|
||||
: 'https://apps.apple.com/ae/app/sefer/id6458734951';
|
||||
showCupertinoDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: Text('Update Available'.tr),
|
||||
content: Text(
|
||||
'A new version of the app is available. Please update to the latest version.'
|
||||
.tr,
|
||||
),
|
||||
actions: <Widget>[
|
||||
CupertinoDialogAction(
|
||||
child: Text('Update'.tr),
|
||||
onPressed: () async {
|
||||
if (await canLaunchUrl(Uri.parse(storeUrl))) {
|
||||
await launchUrl(Uri.parse(storeUrl));
|
||||
} else {
|
||||
print('Could not launch $storeUrl');
|
||||
}
|
||||
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user