25-3/18/1
This commit is contained in:
52
lib/controller/functions/package_info.dart
Normal file → Executable file
52
lib/controller/functions/package_info.dart
Normal file → Executable file
@@ -164,23 +164,45 @@ void showUpdateDialog(BuildContext context) {
|
||||
);
|
||||
}
|
||||
|
||||
getDeviceFingerprint() async {
|
||||
final deviceInfo = await DeviceInfoPlugin().deviceInfo;
|
||||
var deviceData;
|
||||
class DeviceHelper {
|
||||
static Future<String> getDeviceFingerprint() async {
|
||||
final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
|
||||
var deviceData;
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
deviceData = deviceInfo.data;
|
||||
} else if (Platform.isIOS) {
|
||||
deviceData = deviceInfo.data;
|
||||
try {
|
||||
if (Platform.isAndroid) {
|
||||
// Fetch Android-specific device information
|
||||
AndroidDeviceInfo androidInfo = await deviceInfoPlugin.androidInfo;
|
||||
deviceData = androidInfo.toMap(); // Convert to a map for easier access
|
||||
// Log.print('deviceData: ${jsonEncode(deviceData)}');
|
||||
} else if (Platform.isIOS) {
|
||||
// Fetch iOS-specific device information
|
||||
IosDeviceInfo iosInfo = await deviceInfoPlugin.iosInfo;
|
||||
deviceData = iosInfo.toMap(); // Convert to a map for easier access
|
||||
} else {
|
||||
throw UnsupportedError('Unsupported platform');
|
||||
}
|
||||
|
||||
// Extract relevant device information
|
||||
final String deviceId = Platform.isAndroid
|
||||
? deviceData['androidId'] ?? deviceData['serialNumber'] ?? 'unknown'
|
||||
: deviceData['identifierForVendor'] ?? 'unknown';
|
||||
|
||||
final String deviceModel = deviceData['model'] ?? 'unknown';
|
||||
final String osVersion = Platform.isAndroid
|
||||
? deviceData['version']['release'] ?? 'unknown'
|
||||
: deviceData['systemVersion'] ?? 'unknown';
|
||||
|
||||
// Log the extracted information
|
||||
|
||||
// Generate and return the encrypted fingerprint
|
||||
final String fingerprint = '${deviceId}_${deviceModel}_$osVersion';
|
||||
print(EncryptionHelper.instance.encryptData(fingerprint));
|
||||
return EncryptionHelper.instance.encryptData(fingerprint);
|
||||
} catch (e) {
|
||||
throw Exception('Failed to generate device fingerprint');
|
||||
}
|
||||
}
|
||||
|
||||
final String deviceId =
|
||||
deviceData['androidId'] ?? deviceData['identifierForVendor'];
|
||||
final String deviceModel = deviceData['model'];
|
||||
final String osVersion = deviceData['systemVersion'];
|
||||
|
||||
return EncryptionHelper.instance
|
||||
.encryptData('${deviceId}_${deviceModel}_$osVersion');
|
||||
}
|
||||
|
||||
class SecurityHelper {
|
||||
|
||||
Reference in New Issue
Block a user