Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
860 B
3
Indexable
Never
static Future<String?> getEncryptedDeviceId() async {
    final key = Uint8List.fromList(utf8.encode("testingAot123456"));
    final iv = Uint8List.fromList(utf8.encode("testingAot123456"));

    final encrypter = encrypt.Encrypter(encrypt.AES(encrypt.Key(key)));

    if (kIsWeb) return null;

    final deviceInfo = DeviceInfoPlugin();
    if (Platform.isIOS) {
      final iosDeviceInfo = await deviceInfo.iosInfo;

      final encrypted = encrypter
          .encrypt(iosDeviceInfo.identifierForVendor ?? '', iv: encrypt.IV(iv));
      return encrypted.base64; // unique ID on iOS
    } else if (Platform.isAndroid) {
      final androidDeviceInfo = await deviceInfo.androidInfo;
      final encrypted =
          encrypter.encrypt(androidDeviceInfo.id, iv: encrypt.IV(iv));
      return encrypted.base64; // unique ID on Android
    }
    return null;
  }
Leave a Comment