monorepo/dialer/lib/domain/services/obfuscate_service.dart
AlexisDanlos 664dd4bb38
All checks were successful
/ mirror (push) Successful in 5s
/ build-stealth (push) Successful in 8m55s
/ build (push) Successful in 8m58s
WIP: app rework
2025-03-26 22:27:02 +01:00

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 '';
}
}