37 lines
894 B
Dart
37 lines
894 B
Dart
import '../../core/config/app_config.dart';
|
|
|
|
class ObfuscateService {
|
|
// Private constructor
|
|
ObfuscateService._privateConstructor();
|
|
|
|
// Singleton instance
|
|
static final ObfuscateService _instance = ObfuscateService._privateConstructor();
|
|
|
|
// Factory constructor to return the same instance
|
|
factory ObfuscateService() {
|
|
return _instance;
|
|
}
|
|
|
|
// Public method to obfuscate data
|
|
String obfuscateData(String data) {
|
|
if (AppConfig.isStealthMode) {
|
|
return _obfuscateData(data);
|
|
} else {
|
|
return data;
|
|
}
|
|
}
|
|
|
|
// Private helper method for obfuscation logic
|
|
String _obfuscateData(String data) {
|
|
if (data.isNotEmpty) {
|
|
// Ensure the string has at least two characters to obfuscate
|
|
if (data.length == 1) {
|
|
return '${data[0]}';
|
|
} else {
|
|
return '${data[0]}...${data[data.length - 1]}';
|
|
}
|
|
}
|
|
return '';
|
|
}
|
|
}
|